subject

Consider the problem of making change for n cents using the fewest number of coins. Assume that each coin's value is an integer.

a. Suppose that the available coins are in the denominations that are powers of c, i. e., the denominations are c0 ; c1; …; ck for some integers c > 1 and k _ 1. Show that the greedy algorithm of picking the largest denomination first always yields an optimal solution. You are expected to reason about why this approach gives an optimal solution. (Hint: Show that for each denomination ci, the optimal solution must have less than c coins.)

b. Design an Ο(nk) time algorithm that makes a change for any set of k different coin denominations, assuming that one of the coins is 3 cents in value.

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 15:00
Atool that matches persoal skills qualities interests and talets to a career is called a
Answers: 1
question
Computers and Technology, 22.06.2019 22:50
Assume the existence of a bankaccount class. define a derived class, savingsaccount that contains two instance variables: the first a double, named interestrate, and the second an integer named interesttype. the value of the interesttype variable can be 1 for simple interest and 2 for compound interest. there is also a constructor that accepts two parameters: a double that is used to initialize the interestrate variable, and a string that you may assume will contain either "simple", or "compound", and which should be used to initialize the interesttype variable appropriately. there should also be a pair of functions getinterestrate and getinteresttype that return the values of the corresponding data members (as double and int respectively).
Answers: 2
question
Computers and Technology, 23.06.2019 13:30
Spoons are designed to be used for: spring hammering. applying body filler. identifying high and low spots. sanding highly formed areas.
Answers: 3
question
Computers and Technology, 23.06.2019 14:30
The option enables you to modify a slide element in most presentation applications.
Answers: 2
You know the right answer?
Consider the problem of making change for n cents using the fewest number of coins. Assume that each...
Questions
question
Mathematics, 10.09.2020 21:01
question
Mathematics, 10.09.2020 21:01
question
Mathematics, 10.09.2020 21:01
question
Mathematics, 10.09.2020 21:01
question
French, 10.09.2020 21:01
question
Mathematics, 10.09.2020 21:01
question
Mathematics, 10.09.2020 21:01
question
Mathematics, 10.09.2020 21:01
question
Mathematics, 10.09.2020 21:01
question
Mathematics, 10.09.2020 21:01
question
Mathematics, 10.09.2020 21:01
question
Mathematics, 10.09.2020 21:01
question
Arts, 10.09.2020 21:01
question
Mathematics, 10.09.2020 21:01
question
Mathematics, 10.09.2020 21:01
question
Mathematics, 10.09.2020 21:01
question
Mathematics, 10.09.2020 21:01
question
Mathematics, 10.09.2020 21:01
question
Mathematics, 10.09.2020 21:01
question
Mathematics, 10.09.2020 21:01
Questions on the website: 13722359