This preview shows pages 1–8. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: (n/2) th smallest. Note: If this ends up being a good idea, we’d end up coding general selection. Question #1: Does this work? Question #2: Is it a good algorithm? How do we analyze the runtime of something like this? Partitioning takes n1 comparisons. Random number generation may take some time (we'll ignore this for now). The recursion may or may not be needed, and we don’t know exactly how many values will be passed into that recursion. T(n) = n + T(???) The best case is easy, we find it on the first shot and it’s n1 comparisons. What about worst case and average case? We will assume unique values in the list. We’ll round things and say the partitioning takes n comparisons. We will look at “worst” expected runtime. We’ll compute assuming we have to look in the larger of the two sublists (which is true for median finding). We won’t worry about floor/ceiling issues in this initial exploration....
View
Full
Document
This note was uploaded on 01/13/2012 for the course CMSC 351 taught by Professor Staff during the Fall '11 term at University of Louisville.
 Fall '11
 Staff

Click to edit the document details