Data Structures & AlgorithmsModerateGATE CS · Product placement

Merge sort and quick sort are compared. Which statement is correct?

  1. A. Merge sort is in place for arrays and quick sort needs Θ(n) extra space
  2. B. Quick sort is stable and merge sort is not
  3. C. Both have O(n²) worst cases
  4. D. Merge sort guarantees O(n log n) but needs Θ(n) extra space for arrays; quick sort is in place (O(log n) stack expected) but has an O(n²) worst case

Correct answer: D. Merge sort guarantees O(n log n) but needs Θ(n) extra space for arrays; quick sort is in place (O(log n) stack expected) but has an O(n²) worst case

Array merge sort needs an auxiliary buffer; quick sort partitions in place but degrades to Θ(n²) with bad pivots. Neither standard quick sort nor heap sort is stable.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic