Algorithms and Data Structures · Junior · Question 38 of 75

What is the typical time complexity of a good general-purpose comparison sort?

Explanation

Merge sort, heapsort and Timsort (used by V8) run in O(n log n). Simple sorts such as bubble, selection and insertion sort are O(n²) in the worst case.

Further reading

Problem with a question

Algorithms and Data Structures · Junior · question 38

Test yourself

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

Take this quiz