Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
Material Type: Quiz; Professor: Padua-Perez; Class: OBJECT-ORIENTED PROG II; Subject: Computer Science; University: University of Maryland; Term: Unknown 1989;
Typology: Quizzes
1 / 2
The third quiz for the course will be on Friday, July 13. The following list provides more information about the quiz:
The following exercises cover the material to be included in this quiz. Solutions to these exercises will not be provided, but you are welcome to discuss your solutions with the TA or instructor during office hours.
Using the following graph for the questions that follow.
For each of the following exercises, specify the order nodes are visited when performing the appropriate traversal. Pick nodes to visit using alphabetical order (when multiple choices are possible).
a. Apply DFS with A as the start node. b. Apply DFS with C as the start node (assuming edges are undirected). c. Apply BFS with D as the start node. d. Apply BFS with F as the start node (assuming edges are undirected).
For each of the following exercises, assume that all edges are undirected. Apply Dijkstra’s algorithm. Indicate the cost (for lowest weight path) and predecessor for each node in the graph after completing the algorithm. Also list the order nodes are added to the set of processed nodes.
For instance, applying Djikstra’s algorithm with C as the start node yields (after C is processed):
Node A B C D E F Cost ∞ 1 0 25 ∞ 8 Predecessor none C none C none C Order added 1
And after all nodes are processed:
Node A B C D E F Cost 10 1 0 5 7 8 Predecessor E C none B D C Order added 6 2 1 3 4 5
The shortest path to A from C is thus C→B→D→E→A, with a cost of 10.
a. Apply Dijkstra’s algorithm with A as the start node. List shortest path to F. b. Apply Dijkstra’s algorithm with B as the start node. List shortest path to F. c. Apply Dijkstra’s algorithm with E as the start node. List shortest path to C.
For each of the following exercises, assume that all edges in the graph above are undirected. Find the edges in a minimum spanning tree. List the edges in the order they are added to the MST.
a. Apply Prim’s algorithm (to the graph above) with A as the starting node. b. Apply Prim’s algorithm (to the graph above) with F as the starting node. c. Apply Kruskal’s algorithm (to the graph above).
d. Recalculate all 3 answers using the following graph below instead.