Interview concept

What are the main sorting algorithms?

Sorting algorithms arrange elements in order. Comparison-based sorts such as merge sort, quicksort, and heapsort run in O(n log n), while non-comparison sorts like counting and radix sort can reach linear time on bounded keys.

Interview concept

How it works

Merge sort

A stable divide-and-conquer sort with guaranteed O(n log n) time and O(n) extra space.

Quicksort

Partitions around a pivot for fast average O(n log n) time in place, but O(n squared) in the worst case without good pivots.

Stability and space

Interviews often ask whether a sort is stable and how much extra memory it needs.

Interview concept

Responsible use

Use any live AI assistant only where interview, workplace, school, and platform rules allow it. Do not use generated answers to misrepresent your skills, experience, or authorship.

FAQ

Common questions.

Which sorting algorithm is fastest?

Quicksort is often fastest in practice for in-memory arrays, while merge sort guarantees O(n log n) and stability.

What does a stable sort mean?

A stable sort keeps equal elements in their original relative order, which matters when sorting by multiple keys.