The GATE Grind

GATE 2017 CS (CS2) – Question 13

Algorithms · Asymptotic Analysis and Time/Space Complexity · 1 mark · Multiple choice

Match (P) Towers of Hanoi with n disks, (Q) binary search on n sorted numbers, (R) worst-case heap sort on n numbers, (S) addition of two n×n matrices, with (i) Θ(n²), (ii) Θ(n log n), (iii) Θ(2ⁿ), (iv) Θ(log n).

  1. P–iii,Q–iv,R–i,S–ii
  2. P–iv,Q–iii,R–i,S–ii
  3. P–iii,Q–iv,R–ii,S–i
  4. P–iv,Q–ii,R–iii,S–i

Practise this question in The GATE Grind →

Show answer and explanation

Correct answer: (C) P–iii,Q–iv,R–ii,S–i

Explanation

Hanoi uses 2ⁿ−1 moves, Θ(2ⁿ). Binary search halves its search interval, Θ(log n). Heap sort extracts n maxima at logarithmic cost, Θ(n log n). Matrix addition visits n² entries, Θ(n²). Therefore P–iii,Q–iv,R–ii,S–i, C.

More Asymptotic Analysis and Time/Space Complexity questions

All Asymptotic Analysis and Time/Space Complexity questions →