Docsity

Algorithms and Data Structures Test 3 Questions | CP SC 212, Exams of Algorithms and Programming

Toggle sidebar
bg1
CPSC 212-302 Name: _____________________________
Test #3, Part B April 11, 2007
Closed books. Closed Notes. Calculators OK. 85 points. 60 minutes. The weight of each question is
indicated in parentheses. Please use a pencil. If you need more space, use the back of the sheet.
1. (10) Assume that a graph is such that for node i (0 ≤ i < N), there is a directed edge to all nodes j > i.
How many directed edges does this graph have? Be precise. Your answer should be expressed in terms of
N. Explain clearly how you arrived at your answer (you will get at most one point credit if all you give me
is your final answer).
2. (10) Apply Dijkstra’s algorithm to graph G1. Put the final values produced by the algorithm in the table
below. Start with node 5.
dv pv G1:
0 ____ ____
1 ____ ____
2 ____ ____
3 ____ ____
4 ____ ____
5 ____ ____
3. (5) Topological Sort. Consider graph G2. Which of the following is not a topological sort of G2? Mark
each with an “X”.
___ POANBMHGCLJIFKDE
___ PONABMLCDHIJGFKE
___ PAMONBCKHJIGFKDE
___ ABPMONCDHJILKGFE
___ APBCDMLONHJIFGKE
pf3

Partial preview of the text

Download Algorithms and Data Structures Test 3 Questions | CP SC 212 and more Exams Algorithms and Programming in PDF only on Docsity!

CPSC 212-302 Name: _____________________________

Test #3, Part B April 11, 2007

Closed books. Closed Notes. Calculators OK. 85 points. 60 minutes. The weight of each question is indicated in parentheses. Please use a pencil. If you need more space, use the back of the sheet.

  1. (10) Assume that a graph is such that for node i (0 ≤ i < N ), there is a directed edge to all nodes j > i. How many directed edges does this graph have? Be precise. Your answer should be expressed in terms of N. Explain clearly how you arrived at your answer (you will get at most one point credit if all you give me is your final answer).
  2. (10) Apply Dijkstra’s algorithm to graph G1. Put the final values produced by the algorithm in the table below. Start with node 5. dv pv G1: 0 ____ ____ 1 ____ ____ 2 ____ ____ 3 ____ ____ 4 ____ ____ 5 ____ ____
  3. (5) Topological Sort. Consider graph G2. Which of the following is not a topological sort of G2? Mark each with an “X”. ___ POANBMHGCLJIFKDE ___ PONABMLCDHIJGFKE ___ PAMONBCKHJIGFKDE ___ ABPMONCDHJILKGFE ___ APBCDMLONHJIFGKE
  1. (10) Complete the portion of the following decision tree for four values (A, B, C, D) not marked with an “X”.
  2. (10) Apply Kruskal’s algorithm to graph G5 below. Draw the final spanning tree produced by the algorithm in the space on the right. Show clearly how you arrived at your answer!
  3. (10) Apply Prim’s algorithm to graph G5 above. Start with node 5. Draw the final table in the space provided. dv pv 0 ____ ____ 1 ____ ____ 2 ____ ____ 3 ____ ____ 4 ____ ____ 5 ____ ____