Match the algorithms with their time complexities:
View worked solution
Answer: C
We can determine the time complexity of each algorithm as follows:
- P. Tower of Hanoi with disks: The recurrence relation for the number of moves is given by with . Solving this recurrence yields , which is in .
Thus, P → (iii). - Q. Binary Search given sorted numbers: In each step, the search space is halved. The recurrence relation is , which solves to .
Thus, Q → (iv). - R. Heap sort given numbers at the worst case: Heap sort consists of building a max-heap (which takes time) followed by extractions of the maximum element (each taking time). The overall worst-case time complexity is .
Thus, R → (ii). - S. Addition of two matrices: To add two matrices, we perform element-wise addition for each of the positions. This requires additions, resulting in a time complexity of .
Thus, S → (i).
Combining these matches, we get: P → (iii), Q → (iv), R → (ii), S → (i), which corresponds to Option C.
Free practice · Your answers on this page are not saved.
