Skip to content
UPEEC

Best, Average and Worst Case

The same algorithm can behave differently on different inputs.

Easy
Comments 0

Quick sort: best/average O(nlog⁡n)O(n\log n), worst O(n2)O(n^2) on bad pivots. Insertion sort: O(n)O(n) on already-sorted data.

Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.

Discussion (0)

Sign in or join free to ask questions and discuss this topic.