This preview shows page 1. Sign up to view the full content.
Computer Science 130B Spring 2012 Homework #2 Due: 4pm, Feb. 3, Friday Problem 1 Consider the coin change problem. You are at a check out register, and have an unlimited supply of quarters, dimes, nickels, and pennies. You have to make change for a customer. Design a greedy algorithm to make out an amount of x cents that uses the smallest number of coins. Prove the optimality of your algorithm. Problem 2 We know that a minimum-cost spanning tree links all the vertices in a connected undirected graph together in such a way that the total cost of the tree arcs is minimized. Does this fact imply that given two vertices i and j in a graph and a minimum-cost spanning tree of that graph, the shortest path from i to j must contain only the tree arcs in the minimum-cost spanning tree? If you think so, prove it, otherwise, give a counterexample. Problem 3 Consider the graph shown in figure 1. a. Find the shortest path from vertex a to vertex e using Dijkstra’s algorithm. Show intermediate steps in executing
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.
- Spring '12
- Computer Science