What is the time complexity of Merge Sort?

The time complexity of Merge Sort is O(n log n), where 'n' is the number of elements in the array being sorted.

Explanation:

  • Divide: The array is repeatedly divided into halves until individual elements are reached. This process has a time complexity of O(log n), where 'log n' represents the number of times the array can be divided.
  • Merge: After the array is divided, the merging process takes place. In each merging step, all 'n' elements are processed. The number of merging steps is log n because, at each level of the recursion, all elements are processed during the merge phase.

Considering both the divide and conquer steps, the overall time complexity is O(n log n).