Docsity

MCS 401 Final Exam Preparation: Algorithms and Graph Theory - Prof. Anton Leykin, Exams of Algorithms and Programming

Toggle sidebar
bg1
MCS 401 Final: BH 208, 10:30-12:30, Thu, Dec 11, 2008
The following problems are suggested for practice before the final. In addition review homework
problems in the related chapters. The exam will cover
•Dynamic programing, greedy algorithms (concepts only, no memorization of examples is nec-
essary).
•Graph algorithms: BFS, DFS, their applications.
•Minimal spanning trees: Kruskal, Prim.
•Shortest paths algorithms: single-source (Bellman-Ford, Dijkstra), all pairs (Floyd-Warshall).
•Maximum flow: flow networks, Ford-Fulkerson method.
1. A run of depth-first search on a directed graph with vertices A, B, . . . , J yields the following
discovery/finish times:
vertex A B C D E F G H I J
d1 2 10 12 3 13 17 4 6 14
f20 9 11 19 8 16 18 5 7 15
(a) Sketch the predecessor forest created by this run of DFS.
(b) Could the graph have an edge from Jto D? yes no
If so, then what kind? tree, forward, back, cross (underline all possibilities)
(c) Could the graph have an edge from Eto D? yes no
If so, then what kind? tree, forward, back, cross (underline all possibilities)
(d) What is the maximum number of edges starting at Ithat could be present in the graph?
2. Describe an O(n)-time algorithm that, given x1< x2<· · · < xnon the real line, determines
a smallest set of unit-length closed intervals the union of which contains all xi. Prove your
algorithm is correct.
3. Let G= (V, E ) be a directed graph with |V|=nand |E|=m. Suppose that each vertex
u∈Vis labeled with a unique integer L(u) from the set {1,2, . . . , n}. For each u∈V, let
R(u) = {v∈V:u v}be the set of the vertices that can be reached by a directed path
starting from u. Define min(u) to be the vertex in R(u) whose label is minimum. Give an
O(n+m)-time algorithm that computes min(u) for all vertices u∈V.
pf2

Partial preview of the text

Download MCS 401 Final Exam Preparation: Algorithms and Graph Theory - Prof. Anton Leykin and more Exams Algorithms and Programming in PDF only on Docsity!

MCS 401 Final: BH 208, 10:30-12:30, Thu, Dec 11, 2008

The following problems are suggested for practice before the final. In addition review homework problems in the related chapters. The exam will cover

  • Dynamic programing, greedy algorithms (concepts only, no memorization of examples is nec- essary).
  • Graph algorithms: BFS, DFS, their applications.
  • Minimal spanning trees: Kruskal, Prim.
  • Shortest paths algorithms: single-source (Bellman-Ford, Dijkstra), all pairs (Floyd-Warshall).
  • Maximum flow: flow networks, Ford-Fulkerson method.
  1. A run of depth-first search on a directed graph with vertices A, B,... , J yields the following discovery/finish times:

vertex A B C D E F G H I J d 1 2 10 12 3 13 17 4 6 14 f 20 9 11 19 8 16 18 5 7 15

(a) Sketch the predecessor forest created by this run of DFS. (b) Could the graph have an edge from J to D? yes no If so, then what kind? tree, forward, back, cross (underline all possibilities) (c) Could the graph have an edge from E to D? yes no If so, then what kind? tree, forward, back, cross (underline all possibilities) (d) What is the maximum number of edges starting at I that could be present in the graph?

  1. Describe an O(n)-time algorithm that, given x 1 < x 2 < · · · < xn on the real line, determines a smallest set of unit-length closed intervals the union of which contains all xi. Prove your algorithm is correct.
  2. Let G = (V, E) be a directed graph with |V | = n and |E| = m. Suppose that each vertex u ∈ V is labeled with a unique integer L(u) from the set { 1 , 2 ,... , n}. For each u ∈ V , let R(u) = {v ∈ V : u v} be the set of the vertices that can be reached by a directed path starting from u. Define min(u) to be the vertex in R(u) whose label is minimum. Give an O(n + m)-time algorithm that computes min(u) for all vertices u ∈ V.
  1. Given a modification of Kruskal’s algorithm to solve the following problem. Let G = (V, E) be a connected, undirected graphs with weighted edges, and S be a subset of E containing no cycle. Find a spanning tree of G containing S, such that its weight is as small as possible. What is the running time of your algorithm?
  2. Sketch an O(V )-time algorithm that, given a directed graph G = (V, E) and u, v ∈ V , will determine whether there is a path u v.
  3. Consider a directed graph G = (V, E).

(a) Give a definition of a strongly connected component of G. (b) Give a definition of the component graph GSCC. (c) Prove that GSCC^ is acyclic.

  1. The following flow network has edges labeled with pairs of numbers representing flow/capacity. Draw the residual network and give an example of an augmenting path. What additional flow does this path provide?