80 likes | 109 Views
Learn about the K-way Merge Sort algorithm, its efficiency compared to traditional methods, and how changing the base can impact its running time.
E N D
CS1020 Data Structures and Algorithms ILecture Note #14a K-way Merge Sort
1 K-way Merge Sort (1/2) . . . Can we make Merge Sort more efficient by dividing by k instead of 2? [CS1020 Lecture 14a: K-way Merge Sort]
1 K-way Merge Sort (2/2) 5 12 3 9 . . . 10 16 6 7 [CS1020 Lecture 14a: K-way Merge Sort]
2 Running time: O(k Nlogk N) N …… N/k N/k … … N/k2 N/k2 N/k2 N/k2 . . . . . . 1 1 1 1 1 1 1 1 1 1 1 1 1 1 [CS1020 Lecture 14a: K-way Merge Sort]
3 Improved K-way Merge Sort 5 12 3 9 . . . 10 16 6 7 [CS1020 Lecture 14a: K-way Merge Sort]
4 Running time: O(N log2k logk N) N N/k N/k N/k2 N/k2 N/k2 N/k2 . . . . . . 1 1 1 1 1 1 1 1 1 1 1 1 1 1 [CS1020 Lecture 14a: K-way Merge Sort]
4 Running time: O(N log2k logk N) By changing the base, we get O(N log2 N) It is not really an improvement over 2-way Merge Sort But it has real application [CS1020 Lecture 14a: K-way Merge Sort]