Pergunta de entrevista da empresa Microsoft

A form of the knapsack problem, another question on binary trees.