Lecture 7
Learning objectives
After this class, you should be able to:
- Given an array and a sequence of random numbers, show how randomized quicksort will sort the array.
- Analyze the worst case and average case time complexities of quicksort.
- Given a problem, choose a suitable sorting algorithm that will be efficient for that problem.
Reading assignment
- Lectures 6-9 slides.
- CLR: Sections 7.3 - 7.4.
- CLR: Chapter 8, page 192.
Exercises and review questions
- Questions on current lecture's material
- Exercise 7.3-2
- Show that
q2 + (n-1-q)2, 0 < q < n-1
, is maximized whenq = 0
orq = n-1
.- Questions on next lecture's material
- (Post your solution on the discussion board) Give an example of an array that is not already in sorted order, and give the permutation corresponding to this array. Note: The desired permutation is the set of values of
pi(1), pi(2), pi(3), ...
, as presented on page 192, and in particular, in figure 8.1.- What is the maximum number of leaves in a binary tree of height
h
?