Skip to content
GATEiit

GATE CSE 2017 Session 2 Q13: Match Hanoi, binary search, heap sort, matrix addition to complexities

Syllabus topic: Asymptotic worst-case time and space complexity

Question

Match the algorithms with their time complexities:

AlgorithmTime complexity
(P) Towers of Hanoi with n disks(i) Θ(n2)
(Q) Binary search given n sorted numbers(ii) Θ(nlog⁡n)
(R) Heap sort given n numbers at the worst case(iii) Θ(2n)
(S) Addition of two n×n matrices(iv) Θ(log⁡n)

Try it: multiple choice: exactly one correct option

Select one option
Wrong answer costs 1/3 mark in GATE.
Show answer and explanation

Answer: C (official GATE 2017 final answer key)

Concept used: Standard running times: Towers of Hanoi needs 2n−1 moves, binary search halves the range, heap sort is nlog⁡n, and adding n×n matrices touches n2 entries.

Concept notes

Loading notes…

First step: Write the recurrence or operation count for each algorithm, e.g. T(n)=2T(n−1)+1 for Towers of Hanoi.

Full step-by-step solution

Loading…

Answer from the official final answer key. Found a mistake? Use Report issue and we will fix it.

More questions on Asymptotic worst-case time and space complexity

Every PYQ on this topic →

Share this question

WhatsAppDownload image

Source: official GATE 2017 Session 2 CS question paper and final answer key, organised by IIT Roorkee. Question paper · Answer key