hbs4(1) - show why. (d) Give a dynamic programming...

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

View Full Document Right Arrow Icon
CS 473 HBS 4 Spring 2009 CS 473: Undergraduate Algorithms, Spring 2009 HBS 4 1. Let x and y be two elements of a set S whose ranks differ by exactly r . Prove that in a treap for S , the expected length of the unique path from x to y is O ( log r ) 2. Consider the problem of making change for n cents using the least number of coins. (a) Describe a greedy algorithm to make change consisting of quarters, dimes, nickels, and pennies. Prove that your algorithm yields an optimal solution. (b) Suppose that the available coins have the values c 0 , c 1 ,..., c k for some integers c > 1 and k 1. Show that the greedy algorithm always yields an optimal solution. (c) Give a set of 4 coin values for which the greedy algorithm does not yield an optimal solution,
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: show why. (d) Give a dynamic programming algorithm that yields an optimal solution for an arbitrary set of coin values. 3. A heater is a sort of dual treap, in which the priorities of the nodes are given, but their search keys are generate independently and uniformly from the unit interval [ 0,1 ] . You can assume all priorities and keys are distinct. Describe algorithms to perform the operations INSERT and DELETEMIN in a heater. What are the expected worst-case running times of your algorithms? In particular, can you express the expected running time of INSERT in terms of the priority rank of the newly inserted item? 1...
View Full Document

Ask a homework question - tutors are online