the first version of dynamic solution of knapsack problem
added deallocation fo created nodes, no memory leaks now