Skip to main content
Examonaut

Topic 1 · Lesson 5 of 5

Exam technique and practice

Exam technique

  • Keep a neat trace table for algorithms in words or flow charts; examiners mark the values at each step.
  • In sorting, write the full list after every pass and mark the pivots. State when the sort is finished (a pass with no swaps, or every item fixed).
  • In bin packing, show the lower bound calculation and say "rounded up". Say whether a packing is optimal and why.
  • For order questions, write the scale factor clearly: "time ×(n2n1)2\times \left(\frac{n_2}{n_1}\right)^2".
  • For planarity, list the arcs, say which pairs cross, and state the conclusion in words.

Common mistakes

  • Choosing the wrong pivot in a quick sort with an even number of items. Fix: use the item to the right of the middle.
  • Reordering items in a sublist. Fix: items keep their original order on each side of the pivot.
  • Rounding the bin lower bound down. Fix: always round up; 4.1 bins means at least 5.
  • Thinking a non-optimal packing proves nothing. Fix: a packing that meets the lower bound is optimal; one that does not might still be optimal.
  • Confusing Eulerian (every arc once) with Hamiltonian (every vertex once).
  • Saying a graph is non-planar because the drawing has crossings. Fix: use the planarity algorithm.

Check yourself

  1. Carry out the first pass of a bubble sort, into descending order, on 4,9,2,7,84, 9, 2, 7, 8.
  2. A list of 10 items is sorted by bubble sort. What is the largest possible number of comparisons?
  3. Items of size 6,4,9,7,3,56, 4, 9, 7, 3, 5 are packed into bins of size 12. Find the lower bound and the first-fit decreasing packing.
  4. An algorithm of cubic order takes 3 seconds for n=20n = 20. Estimate the time for n=60n = 60.
  5. How many arcs does K9K_9 have? Is K9K_9 Eulerian?
  6. A graph has degrees 4,3,3,2,24, 3, 3, 2, 2. How many arcs does it have? Is it Eulerian, semi-Eulerian or neither?
  7. A tree has 15 arcs. How many vertices does it have?
  8. With Hamiltonian cycle ABCDEFA, do the arcs AC and BF cross?
Show answers
  1. 9,4,7,8,29, 4, 7, 8, 2
  2. 12×10×9=45\frac{1}{2} \times 10 \times 9 = 45
  3. Total 34, lower bound 3412=2.83\frac{34}{12} = 2.83, so 3; first-fit decreasing: 9, 3 / 7, 5 / 6, 4: three bins, optimal
  4. 3×33=813 \times 3^3 = 81 seconds
  5. 36 arcs; every degree is 8, which is even, so yes
  6. Total 14, so 7 arcs; two odd vertices, so semi-Eulerian (if connected)
  7. 16
  8. Yes: A, B, C, F alternate round the cycle

Practise this topic

Both are part of Premium.