UGC-NET Jun 2014 · Heap Sort & Non-Comparison Sorts

MCQ · 2 marks · Problem PROG-SORT-0004

Mergesort makes two recursive calls. Which statement is true after these two recursive calls finish, but before the merge step ?
  1. A
    The array elements form a heap.
  2. B
    Elements in each half of the array are sorted amongst themselves.
  3. C
    Elements in the first half of the array are less than or equal to elements in second half of the array.
  4. D
    All of the above

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

Show the worked solutionMerge sort sorts the left half and the right half recursively, then merges them. After the two calls each half is sorted on its own, but nothing relates the two halves yet.(A) Two sorted halves need not form a heap, e.g. [5, 9, 1, 3] — incorrect.(C) The halves are split by position, not by value, so a small element may still be in the second half (in [5, 9, 1, 3] the 1 and 3 belong before the 5) — incorrect.(D) Fails because (A) and (C) fail.Answer: B

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