Efficient Algorithms and Problem Complexity – More about Sorting and Selection –
Frank Drewes Department of Computing Science Ume˚ a University
Frank Drewes (Ume˚ a University) Efficient Algorithms and Problem Complexity Lecture 3 1 / 15
Efficient Algorithms and Problem Complexity More about Sorting and - - PowerPoint PPT Presentation
Efficient Algorithms and Problem Complexity More about Sorting and Selection Frank Drewes Department of Computing Science Ume a University Frank Drewes (Ume a University) Efficient Algorithms and Problem Complexity Lecture 3 1
Frank Drewes (Ume˚ a University) Efficient Algorithms and Problem Complexity Lecture 3 1 / 15
Outline
Frank Drewes (Ume˚ a University) Efficient Algorithms and Problem Complexity Lecture 3 2 / 15
The Complexity of Comparison-Based Sorting
Frank Drewes (Ume˚ a University) Efficient Algorithms and Problem Complexity Lecture 3 3 / 15
The Complexity of Comparison-Based Sorting
Frank Drewes (Ume˚ a University) Efficient Algorithms and Problem Complexity Lecture 3 4 / 15
The Complexity of Comparison-Based Sorting
Frank Drewes (Ume˚ a University) Efficient Algorithms and Problem Complexity Lecture 3 5 / 15
The Complexity of Comparison-Based Sorting
Frank Drewes (Ume˚ a University) Efficient Algorithms and Problem Complexity Lecture 3 6 / 15
The Complexity of Comparison-Based Sorting
Frank Drewes (Ume˚ a University) Efficient Algorithms and Problem Complexity Lecture 3 7 / 15
The Complexity of Comparison-Based Sorting
Frank Drewes (Ume˚ a University) Efficient Algorithms and Problem Complexity Lecture 3 8 / 15
The Complexity of Comparison-Based Sorting
Frank Drewes (Ume˚ a University) Efficient Algorithms and Problem Complexity Lecture 3 9 / 15
Sorting Integers
1 Compute c[1 · · · m] where c[k] = |{i | a[i] = k}|.
2 Scan c to replace every c[k] with c[k] = |{i | a[i] ≤ k}|.
3 Scan a backwards to put each a[i] into b[c[a[i]]−−].
Frank Drewes (Ume˚ a University) Efficient Algorithms and Problem Complexity Lecture 3 10 / 15
Sorting Integers
Frank Drewes (Ume˚ a University) Efficient Algorithms and Problem Complexity Lecture 3 11 / 15
Selection
Frank Drewes (Ume˚ a University) Efficient Algorithms and Problem Complexity Lecture 3 12 / 15
Selection
Frank Drewes (Ume˚ a University) Efficient Algorithms and Problem Complexity Lecture 3 13 / 15
Selection
Frank Drewes (Ume˚ a University) Efficient Algorithms and Problem Complexity Lecture 3 14 / 15
Selection
Frank Drewes (Ume˚ a University) Efficient Algorithms and Problem Complexity Lecture 3 15 / 15