Curated · Heap Sort & Non-Comparison Sorts

MCQ · 1 mark · Problem PROG-SORT-0068

Merge sort divides an array into two halves, sorts them recursively and merges them. Its running time on n elements in the worst case is
  1. A
    \(\Theta(n)\)
  2. B
    \(\Theta(n^2)\)
  3. C
    \(\Theta(\log n)\)
  4. D
    \(\Theta(n\log n)\)

Solve it on GATE DA practice →More Searching & Sorting Algorithms problems

Show the worked solutionMerge sort splits the array into two halves, sorts each recursively, and merges them in linear time:\(T(n)=2T(n/2)+\Theta(n)\).By the Master theorem (case 2, since \(n^{\log_2 2}=n\) matches the \(\Theta(n)\) term), \(T(n)=\Theta(n\log n)\).The splitting and merging do not depend on the input order, so this holds in the best, average and worst case.Answer: \(\Theta(n\log n)\)Click to Join Our Telegram Group for Latest Update of MOCK TEST Click Here to Practice ALL Previous MOCK TEST FREE

GATE DA practice: past exam problems by chapter, with worked solutions · gatedaprep.com