ALGO COMPLEXITY MODULE 3 Lesson 7
ALGO COMPLEXITY MODULE 3 Lesson 7
ALGO COMPLEXITY MODULE 3 Lesson 7
Lesson 7
MERGE SORT
Merge Sort
The process of merging two sorted lists together is O(n). Merge sort,
effectively, does this O(log n) times because it splits the list in half at every
step. So, that makes the overall efficiency O(n log n).
Module III
19
Algorithm
The algorithm works as follows:
1. Divide the array in half.
2. Recursively sort both halves.
3. Merge the halves back together.
Sample Implementation
Module III
20
Module III