Engrain by ByteRush

DSA.04.02 Mid-levelCore — asked often

Merge sort, quicksort and heapsort

Comes up in: DSA, Recruiter screen

This concept is being written. It gets the full five steps — explanation, predict, interview angle, practice with tests, and review cards. Here is exactly what it will cover, so you can study it elsewhere in the meantime.

What it covers

  • divide and conquer
  • merge sort O(n log n) stable, O(n) space
  • quicksort average O(n log n), worst O(n²), pivot choice
  • heapsort
  • lower bound for comparison sorts
  • counting/radix sort for integers

Words you will know

divide and conquerpivotpartitioncomparison sort

What you will practise

  • implement merge sort and quicksort

Interview questions this answers

  • Compare merge sort and quicksort.
  • When can you sort faster than O(n log n)?