Data Structure Time Complexity Question #15267
MCQ Single Best Answer Easy

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

ID: #15267 Time Complexity 192 views
Question Info
#15267Q 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: Option D

Explanation

Merge sort is a divide-and-conquer sorting algorithm that divides the array into smaller subarrays, recursively sorts them, and merges them to obtain the sorted array. In each recursion, the array is divided in half, resulting in a logarithmic number of levels. At each level, the merge operation combines two sorted subarrays, which takes linear time. 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.