




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
Information about a computer science exam focusing on graph algorithms, including dfs tree drawing, dijkstra's algorithm, prim's algorithm, and kruskal's algorithm. The exam includes problems related to drawing dfs trees, executing dijkstra, prim, and kruskal algorithms, and answering true or false statements. Additionally, there is a problem about a recurrence equation and pert diagrams.
Typology: Exams
1 / 8
This page cannot be seen from the preview
Don't miss anything!





One page of notes is permitted. No electronic devices, e.g. cell phones and calculators, are permitted. Do all your work on the pages of this examination. If you need more space, you may use the reverse side of the page, but try to use the reverse of the same page where the problem is stated.
You have 80 minutes. The questions are of varying difficulty, so avoid spending too long on any one question.
In all algorithm design problems, you may use high-level pseudocode.
Figure 1 : Graph for Problem 1. Assume for all figures that the adjacency lists are ordered so that vertices are ordered in alphabetical order in an adjacency list.
For example, the adjacency list of A has the edge to B before the edge to D.
Draw the DFS tree of the graph in Figure 1 that will result if the first call to DFS is on vertex A and label each vertex with its pre(in)-and post(out)-order numbers. As per our standing convention, draw tree edges as solid lines, and back, cross, and forward edges as dashed lines. Put a ’B’, ’C’, or ’F’ on each dashed line according to whether it is a back, cross, or forward edge.
Figure 3 : Graph for Problem 3.
(a) Execute Prim’s algorithm on the graph of Figure 3 starting at vertex A. If there are any ties, the vertex with the lower letter comes first. List the edges in the order in which they are added to the tree.
(b) Execute Kruskal’s algorithm on the graph of Figure 3 starting at vertex A. Assume that equal weight edges are ordered lexicographically by the labels of their vertices assuming that the lower labeled vertex always comes first when specifying an edge, e.g. (C, E) is before (C, F) which in turn is before (D, G). List the edges in the order in which they are added to the developing forest.
For each statement below, say whether it is true or false, and give a one sentence and/or one picture explanation.
(a) In an undirected graph, we write s ~k t if and only if there are k vertex disjoint paths between vertices s and t. Is ~k is an equivalence relation for all choices of k?
(b) T(n) = 4T(n/2) + log n is solvable with the Master Theorem.
(c) Suppose T is a shortest paths tree for Dijkstra’s algorithm. After adding c > 0 to every edge in the graph, T is still a shortest paths tree for the modified graph.
(d) It is possible to find a heaviest weight path of exactly k edges from s to each vertex in a directed graph in O(kE) time.
(e) The heaviest edge in a graph cannot belong to a minimum spanning tree.
A PERT diagram is a business standard for planning and charting a multi-task project. Each task to be performed is modeled as a vertex. The longest and shortest time, short(v) and long(v), are given for each task v. In addition, there are dependencies between the tasks modeled as directed edges, where v → w if task v must precede task w. For example, in a construction project the electrical and plumbing cannot be done until the framing has been completed.
Given a directed graph for a PERT chart, along with the short and long values for each vertex, give an algorithm that first checks that the diagram is acyclic, and then if so, gives the most optimistic (shortest) and most pessimistic (longest) completion times for the entire project.
Consider a positively weighted directed graph. Design the most efficient algorithm you can for finding a minimum weight simple cycle in the graph. Be sure to prove that your algorithm is correct and to argue carefully its running time.