A Tree Search Approach to the M-Partition and Knapsack Problems