Time ComplexityLesson 51Free preview
Merge Sort
This lesson is part of DSA · All levels
Summary
Merge sort always O(n log n) because the division tree has log n levels and each level combines a total of n elements. The best and worst cases are the same because the division does not depend on the content of the data. The disadvantage is that merge requires additional memory, so the total space complexity is P1.
Key points
- Time in all cases
- Log n level divided by the work O(n) per level
- Space complexity for the merger buffer
- Stable so the order of the twin elements is awake
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.