hw3 - Computer Science 130B Winter 2012 Homework #3 Due:...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Computer Science 130B Winter 2012 Homework #3 Due: 4:00pm Feb 24th Problem 1 We show in written assignment # 2 that the greedy algorithm can solve the coin change problem where the denominations of coins are 1 (penny), 5 (nickel), 10 (dime), and 25 (quarter). Do you think that the greedy algorithm will work for all possible coin denominations? If yes, prove that the greedy algorithm always uses the smallest number of coins to make change for any coin denomination. If not, given a counterexample that the greedy algorithm may not use the smallest number of coins to make change, and then design a dynamic programming algorithm that solves the coin change problem using the smallest number of coins. What is the complexity of your algorithm? Problem 2 Consider the all-pairs-shortest-paths problem again. Recall that we discussed a dynamic programming solution which can be stated as: A k ( i, j ) = min { A k - 1 ( i, j ) , A k - 1 ( i, k ) + A k - 1 ( k, j ) } . Or, the shortest path between vertices
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/19/2012 for the course ENGR 361 taught by Professor Drexel during the Spring '12 term at Bloomsburg.

Ask a homework question - tutors are online