{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# hw2 - Computer Science 130B Spring 2012 Homework#2 Due 4pm...

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 the algorithm.
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern