Skip to main content
Examonaut

Topic 2 · Lesson 4 of 4

Exam technique and practice

Exam technique

  • Kruskal's: list every arc considered, in order, with include or reject. Prim's: list the arcs in the order they are added. Questions often say "you must list the arcs in the order that you consider them": no list, no marks.
  • State the weight of the tree, with units.
  • Dijkstra's: fill in every box completely, with working values in the order you wrote them. Do not cross out a value you replaced; write the new, smaller one after it.
  • Give the route as a list of vertices (A B E D F) and its length.
  • Floyd's: show both tables after each iteration (or as many as the question asks). Many students lose marks by updating the distance table but not the route table.

Common mistakes

  • Rejecting an arc in Kruskal's because it is not joined to the tree. Fix: Kruskal's only rejects arcs that make a cycle.
  • Stopping Prim's on a matrix too early. Fix: there are n−1n - 1 arcs; every row must be crossed out.
  • Writing a working value that is larger than the existing one. Fix: only write a new working value when it is smaller.
  • Making a vertex final because it was found first. Fix: the next final value is always the smallest working value among all unfinished vertices.
  • Copying the wrong route entry in Floyd's. Fix: the new entry in row X, column Y is copied from row X, column kk (the first step towards kk), not from row kk.

Check yourself

  1. How many arcs are in a minimum spanning tree for a network with 12 vertices?
  2. Why can Prim's algorithm never create a cycle?
  3. In Kruskal's algorithm on the example network, at which point would the arc CE (weight 10) be considered, and would it be included?
  4. In Dijkstra's algorithm, vertex P has working values 19 and 15, and is then made final. What is its final value?
  5. Using the example network, what is the shortest distance from A to D?
  6. In Floyd's algorithm with intermediate vertex C, d(A,C)=5d(A, C) = 5, d(C,D)=4d(C, D) = 4 and d(A,D)=11d(A, D) = 11. What happens to row A, column D in each table, if row A, column C of the route table is B?
  7. State one reason why Prim's algorithm is preferred to Kruskal's for large networks stored as tables.
Show answers
  1. 11
  2. Each new arc joins a vertex in the tree to one not yet in it, so it cannot close a loop
  3. After DF (8), with BD (10); by then the tree is already complete, but if considered it would be rejected, as C and E are already connected
  4. 15
  5. 16 (A B E D)
  6. The distance becomes 9 and the route entry becomes B
  7. It works directly on the table, without sorting all the arcs first or checking for cycles

Practise this topic

Both are part of Premium.