A thief walks into a house. To his surprise, the thief discovers that the owner of the house has pulverized all his precious metals into fine dust. The thief can thus scoop whatever amount he wants. Because of the density of the precious metals and the amazing strength of his back pack, it can accommodate a total of dust.
In the house there is
1 2 3 4 5
If he packs his bag optimally, how much money worth of metals will he walk out with?
There are female dancers with heights and male dancers with heights . The problem is to assign each male dancer to a female dancer and minimize the average difference between the height of the male and the female. Consider the greedy solution to this problem. What is the overall complexity(including sorting) of this algorithm?
Given a set of denominations , we want to make coin change for a specified amount , which we will assume is achievable with the denominations we have access to.
If we want to use as few coins as possible, the greedy approach would be to build a pile of coins by always adding the largest coin which doesn't make the total value of the pile larger than .
This approach doesn't always work, but for some denominations it always gives the optimal solution.
For which set of coin denominations will this approach correctly give us an optimal solution?