

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Perform depth-first search on the graph shown above. For each vertex show the pre-order and post-order numbers, and label each edge with T, F, B, C depending on whether it is a tree, forward, back or cross edge. (As always, when in DFS we have a choice, we always select the alphabetically first vertex.)
Can you add an edge to this graph to make it strongly connected?
A. Brief description or pseudocode for the preprocessing
B. Brief description or pseudocode for answering a query
CS 170, Fall 1998 Midterm 1 1
C. Justification of correctness (for both).
D. Running time and justification (for both).
Give the order in which edges will be added to the MST by Prim's algorithm. Start the algorithm from vertex A.
Repeat for Kruskal's algorithm.
Show the final configuration of the UNION-FIND tree at the end of Kruskal's algorithm. (UNION-FIND means of course "with path compression". In case of ties, always make the alphabetically larger node the root.)
We are given a graph with weights on its vertices. The weight of a path is the sum of the weights of the vertices on the path --including the endpoints. Give an algorithm for finding a shortest path between two nodes s and t. Your algorithm should run as fast as Dijkstra's.
A. Brief description or pseudocode
Problem #2 2