UGC-NET Jul 2016 · Divide & Conquer: Quicksort

MCQ · 2 marks · Problem PROG-DIVC-0035

Match the following : $\begin{array}{clcl}  \text{(a)} & \text{Huffman Code} & \text{(i)} & O(n^2)  \\ \text{(b)} & \text{Optical Polygon Triangulation} & \text{(ii)} & \theta(n^2) \\  \text{(c)} & \text{Activity Selection Problem} & \text{(iii)} & O(n\lg n) \\ \text{(d)} & \text{Quicksort} & \text{(iv)} & \theta(n) \\ \end{array}$ $\textbf{Codes :}$
  1. A
    $\text{(a)-(i), (b)-(ii), (c)-(iv), (d)-(iii)}$
  2. B
    $\text{(a)-(i), (b)-(iv), (c)-((ii), (d)-(iii)}$
  3. C
    $\text{(a)-(iii), (b)-(ii), (c)-(iv), (d)-(i)}$
  4. D
    $\text{(a)-(iii), (b)-(iv), (c)-(ii), (d)-(i)}$

Solve it on GATE DA practice →More Searching & Sorting Algorithms problems

Show the worked solution(a) Huffman coding with a min-heap does \(n-1\) extract-and-merge steps of \(O(\lg n)\): \(O(n\lg n)\), so (a)-(iii).(b) Optimal polygon triangulation is a dynamic program over a \(\Theta(n^2)\) table of sub-polygons (same structure as matrix-chain order), so (b)-(ii).(c) Activity selection on activities already sorted by finish time is a single greedy scan: \(\Theta(n)\), so (c)-(iv).(d) Quicksort is \(O(n^2)\) in the worst case, so (d)-(i).Only option C has (a)-(iii) together with (c)-(iv); option D would give activity selection \(\Theta(n^2)\), which is wrong.Answer: C

GATE DA practice: past exam problems by chapter, with worked solutions · gatedaprep.com