Lecture 33
Learning objectives
After this class, you should be able to:
- Given data to be sorted, show the data after each step of (i) bubble sort and (ii) insertion sort.
- Derive the time complexity for bubble sort and insertion sort.
- If the data is almost sorted, then explain which sorting algorithm would be better, bubble sort or insertion sort.
- Derive a lower bound on simple sorting algorithms.
Reading assignment
- Section 7, sections 7.2, 7.3.
- Lecture: Sorting.
Exercises and review questions
- Exercises and review questions on current lecture's material
- Show the steps involved in sorting the following data using (i) bubble sort and (ii) insertion sort:
16 14 10 8 7 9 3 2 4 1
.- Improve the best case time for bubble sort by first checking if the data is already sorted, in
O(n)
time. If the data is almost sorted, then does this modification help?- Questions on next lecture's material
- None.
Last modified: 22 Nov 2011