Data Structure Time Complexity Question #15248
Single Choice Easy

QWhat is the time complexity of a merge sort algorithm for sorting an array of n elements in the worst case?

ID: #15248 Time Complexity 140 views
Question Info
#15248Q ID
EasyDifficulty
Time ComplexityTopic

Choose the Best Option

Click any option to instantly check if you're correct.

  • A O(1)
  • B O(log n)
  • C O(n)
  • D O(n log n)
Correct Answer

Explanation

Merge sort is a divide-and-conquer sorting algorithm that recursively divides the array into smaller subarrays, sorts them individually, and then merges them back together. In each recursive call, the array is split in half, resulting in a logarithmic number of divisions. Afterward, the merging process takes linear time to combine the sorted subarrays. Therefore, the time complexity of merge sort in the worst case is O(n log n).

Share This Question

Challenge a friend or share with your study group.