Lecture 10
Learning objectives
After this class, you should be able to:
- Give algorithms to determine the minimum and maximum of a set of numbers, and determine the maximum number of comparisons performed.
- Given an array of
n
numbers, an integeri
,1 < i < n
, and a sequence of random numbers in(0, 1)
, show the steps performed by the randomized expected time algorithm in determining thei
th smallest element in the array.- Derive the expected time complexity of the randomized selection algorithm discussed in class.
Reading assignment
- Lecture 10 slides.
- CLR: Chapter 9, up to (and including) section 9.2.
- CLR: Chapter 15, page 371.
Exercises and review questions
- Questions on current lecture's material
- Write C/C++ code implementing the algorithm given in section 9.1 for finding the minimum and maximum simultaneously.
- Give a divide and conquer algorithm to find the minimum and maximum simultaneously, and determine the worst case number of comparisons.
- (Post your solution on the discussion board) Give a sequence of random numbers in
(0, 1)
, and show how the randomized selection algorithm of section 9.2 will use it to determine the3
rd smallest number in the array:8, 6, 3, 2, 9, 0, 4, 1, 7, 5
. Your random number sequence should be chosen such that it does not yield the answer after just one partitioning.- Questions on next lecture's material
- (Post your answer on the discussion board) Give an example of a 3 x 3 matrix and a 3 x 2 matrix, and give their product.