Algorithms and Data Structures · Senior · Question 31 of 75

Why does Timsort perform so well on real-world data?

Explanation

Real data is often partially ordered: appended logs, mostly sorted lists. Timsort finds ascending (or reversed descending) runs, extends short ones with insertion sort and merges them with galloping, approaching O(n) on nearly sorted input.

Further reading

Problem with a question

Algorithms and Data Structures · Senior · question 31

Test yourself

Take the Algorithms and Data Structures · Senior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz