UGC-NET Dec 2015 · Selection Sort

MCQ · 2 marks · Problem PROG-SORT-0010

An ideal sort is an in-place-sort whose additional space requirement is
  1. A
    O (log$_2$ n)
  2. B
    O (nlog$_2$ n)
  3. C
    O (1)
  4. D
    O (n)

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

Show the worked solutionAn in-place sort rearranges the elements inside the input array itself, using only a constant number of extra variables (indices, a temporary for swaps).\[\text{extra space}=O(1).\]Heapsort, insertion sort and selection sort meet this; merge sort needs \(O(n)\) and recursive quicksort \(O(\log n)\) stack space.Answer: C

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