Question:

What is the time complexity of merge sort in the worst case?

Show Hint

Merge sort’s consistent $O(n \log n)$ complexity makes it efficient for large datasets.
Updated On: Jun 18, 2025
  • $O(n \log n)$
  • $O(n^2)$
  • $O(n)$
  • $O(\log n)$
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is A

Solution and Explanation

Merge sort divides the array into two halves recursively until single elements remain, then merges them back in sorted order.
The recurrence relation is:
\[ T(n) = 2T(n/2) + O(n) \]
- Dividing: $O(1)$
- Merging: $O(n)$
- Depth of recursion: $\log n$
Total time: $O(n) \cdot \log n = O(n \log n)$.
This holds for all cases (best, average, worst).
Was this answer helpful?
0
0