MidtermPracticeProblems_Hints.pdf

# Initially the 10 gallon container holds no water and

• Test Prep
• 4
• 100% (1) 1 out of 1 people found this document helpful

This preview shows pages 3–4. Sign up to view the full content.

Initially, the 10 gallon container holds no water, and the 7 gallon and 4 gallon containers are both full. Is there a sequence of moves that leaves exactly 2 gallons in either the 7 gallon or 4 gallon container? Model this as a graph problem. Which algorithm should you apply to deter- mine whether such a sequence exists? Solution Hint: Let each vertex in the graph represent a distribution of water among the 3 containers (e.g., (10, 0, 1) indicates that the first container has 10 gallons and the last container has 1 gallon, and (0, 7, 4) indicates the starting condition). Let edges represent legal moves. 10. a. Prove that in any connected, undirected graph, it is possible to remove some vertex and still leave the graph connected. b. Give an example of a strongly connected directed graph such that removal of any vertex results in a graph that is not strongly connected. Solution Hint: Remove a leaf of the DFS tree. Is the rest of the graph still connected? 11. You are given a strongly connected directed graph G , and a specified 3

This preview has intentionally blurred sections. Sign up to view the full version.

node u . Create an efficient algorithm that finds the shortest- u -paths be- tween all pairs of nodes in G , where the shortest- u -path from s to t is the shortest path from s to t that passes through u . Solution Hint: How can you describe a shortest- u -path from s to t ? Think of the in-class exercise where we created an algorithm to decide which road to add to a graph. 4
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