Easy Sorting Question 59 of 224

How does quicksort work, and what is its average versus worst-case complexity?

DSA interview set · Speak this in 60–90 seconds · Faridabad & Delhi NCR

PICTURE THIS: 1, 2, 2, 8

Mean3.25average
Median2middle
Mode2most often

Simple meaning

Pick a pivot, partition smaller keys left and larger right, then recurse.

1

WHY — Sorting instead of guessing?

Why interviewers care about Sorting:

They want a clean

contrast on Sorting, not two memorised paragraphs.

Say what changes for

the developer, then one case where picking wrong hurts.

Stay structured

Name the idea, why it exists, then one short example.

Close cleanly

End with when you use it and one common pitfall.

2

STEPS — What happens step by step?

Before you speak the answer, walk the interviewer through these steps:

  1. 1
    Pick a pivot, partition

    smaller keys left and larger right, then recurse.

  2. 2
    Average time is O(n

    log n) with O(log n) stack space

  3. 3
    worst case is O(n^2)

    on already-sorted data with a bad pivot.

  4. 4
    Random or median-of-three pivots

    make the worst case unlikely.

  5. 5
    Common mistake

    What juniors usually get wrong.

  6. 6
    Close

    When you pick this over the alternative.

3

EXAMPLE — See it in action

Here's a short line you can speak, broken into clear beats:

Say this line
“Average time is O(n log n) with O(log n) stack space”
Break into beats
AveragetimeisOnlog
Speaking order
2987408337471632900

Note: Adapt this scaffold to your own project — keep it under 60–90 seconds.

Key takeaway

Pick a pivot, partition smaller keys left and larger right, then recurse. Average time is O(n log n) with O(log n) stack space

Chat with us