A branch and bound algorithm for the knapsack problem