12.07.2015 Views

A Practical Introduction to Data Structures and Algorithm Analysis

A Practical Introduction to Data Structures and Algorithm Analysis

A Practical Introduction to Data Structures and Algorithm Analysis

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

528 Chap. 15 Lower Bounds15.2 Single-elimination <strong>to</strong>urnaments are no<strong>to</strong>rious for their scheduling difficulties.Imagine that you are organizing a <strong>to</strong>urnament for n basketball teams(you may assume that n = 2 i for some integer i). We will further simplifythings by assuming that each game takes less than an hour, <strong>and</strong> that each teamcan be scheduled for a game every hour if necessary. (Note that everythingsaid here about basketball courts is also true about processors in a parallelalgorithm <strong>to</strong> solve the maximum-finding problem).(a) How many basketball courts do we need <strong>to</strong> insure that every team canplay whenever we want <strong>to</strong> minimize the <strong>to</strong>tal <strong>to</strong>urnament time?(b) How long will the <strong>to</strong>urnament be in this case?(c) What is the <strong>to</strong>tal number of “court-hours” available? How many <strong>to</strong>talhours are courts being used? How many <strong>to</strong>tal court-hours are unused?(d) Modify the algorithm in such a way as <strong>to</strong> reduce the <strong>to</strong>tal number ofcourts needed, by perhaps not letting every team play whenever possible.This will increase the <strong>to</strong>tal hours of the <strong>to</strong>urnament, but try <strong>to</strong> keepthe increase as low as possible. For your new algorithm, how long is the<strong>to</strong>urnament, how many courts are needed, how many <strong>to</strong>tal court-hoursare available, how many court-hours are used, <strong>and</strong> how many unused?15.3 Explain why the cost of splitting a list of six in<strong>to</strong> two lists of three <strong>to</strong> find theminimum <strong>and</strong> maximum elements requires eight comparisons, while splittingthe list in<strong>to</strong> a list of two <strong>and</strong> a list of four costs only seven comparisons.15.4 Write out a table showing the number of comparisons required <strong>to</strong> find theminimum <strong>and</strong> maximum for all divisions for all values of n ≤ 13.15.5 Present an adversary argument as a lower bounds proof <strong>to</strong> show that n − 1comparisons are necessary <strong>to</strong> find the maximum of n values in the worst case.15.6 Present an adversary argument as a lower bounds proof <strong>to</strong> show that n comparisonsare necessary in the worst case when searching for an element withvalue X (if one exists) from among n elements.15.7 Section 15.6 claims that by picking a pivot that always discards at least afixed fraction c of the remaining array, the resulting algorithm will be linear.Explain why this is true. Hint: The Master Theorem (Theorem 14.1) mighthelp you.15.8 Show that any comparison-based algorithm for finding the median must useat least n − 1 comparisons.15.9 Show that any comparison-based algorithm for finding the second-smalles<strong>to</strong>f n values can be extended <strong>to</strong> find the smallest value also, without requiringany more comparisons <strong>to</strong> be performed.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!