heapsort and knapsack