Q17.Marks: +2.0UGC NET Paper 2: Computer Science 2nd January 2026 Shift 1
Which of the following is correct order of increasing time complexity of algorithms
A. Tower of Hanoi with n disk.
B. Binary search given n sorted numbers.
C. Heap sort given n numbers at the worst case.
D. Addition of two n x n matrices.
Choose the correct answer from the options given below:
1.B, C, D, A✓ Correct
2.A, B, C, D
3.D, C, B, A
4.C, A, D, B
Solution
The correct answer is Option 1.
Key Points
The correct order of increasing time complexity of algorithms is: B, C, D, A.
Binary Search: The time complexity of binary search is O(log n), as it divides the search space into half with every iteration.
Heap Sort: In the worst case, the time complexity of heap sort is O(n log n), as it involves building a heap and performing repeated heapify operations.
Addition of Two n x n Matrices: The time complexity of adding two matrices is O(n²), as each element of the matrices is accessed once.
Tower of Hanoi: The time complexity of solving the Tower of Hanoi problem with n disks is O(2ⁿ), as it involves exponential recursion.
Additional Information
Time Complexity Overview:
Binary Search (O(log n)): Efficient for searching in sorted data, requires logarithmic time.
Heap Sort (O(n log n)): A comparison-based sorting algorithm with good performance in the worst case.
Matrix Addition (O(n²)): Involves iterating through all n² elements of the matrices to compute the sum.
Tower of Hanoi (O(2ⁿ)): A classic recursive problem with exponential growth in the number of moves as n increases.
Practical Implications:
Binary Search is highly efficient for large datasets and is commonly used in search algorithms.
Heap Sort is a reliable sorting algorithm with consistent performance across different cases.
Matrix addition is computationally intensive for large matrices, but it is straightforward to implement.
The Tower of Hanoi problem demonstrates the limitations of recursive algorithms for large inputs.
Important Points:
Understanding time complexity helps in selecting the right algorithm for specific problems.
Algorithms with exponential time complexity, like the Tower of Hanoi, become impractical for large input sizes.
Efficient algorithms like Binary Search and Heap Sort are crucial in optimizing performance in real-world applications.