11.07.2015 Views

Data Structures and Algorithm Analysis - Computer Science at ...

Data Structures and Algorithm Analysis - Computer Science at ...

Data Structures and Algorithm Analysis - Computer Science at ...

SHOW MORE
SHOW LESS

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

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

504 Chap. 15 Lower Bounds1234Figure 15.7 Merge insert sort for ten elements. First five pairs of elements arecompared. The five winners are then sorted. This leaves the elements labeled 1-4to be sorted into the chain made by the remaining six elements.Call the optimal worst cost for n elements S(n). We know th<strong>at</strong> S(n + 1) ≤S(n) + ⌈log(n + 1)⌉ because we could sort n elements <strong>and</strong> use binary insert for thelast one. For all n <strong>and</strong> m, S(n + m) ≤ S(n) + S(m) + M(m, n) where M(m, n)is the best time to merge two sorted lists. For n = 47, it turns out th<strong>at</strong> we can dobetter by splitting the list into pieces of size 5 <strong>and</strong> 42, <strong>and</strong> then merging. Thus,merge sort is not quite optimal. But it is extremely good, <strong>and</strong> nearly optimal forsmallish numbers of elements.15.8 Further ReadingMuch of the m<strong>at</strong>erial in this book is also covered in many other textbooks on d<strong>at</strong>astructures <strong>and</strong> algorithms. The biggest exception is th<strong>at</strong> not many other textbookscover lower bounds proofs in any significant detail, as is done in this chapter. Thoseth<strong>at</strong> do focus on the same example problems (search <strong>and</strong> selection) because it tellssuch a tight <strong>and</strong> compelling story regarding rel<strong>at</strong>ed topics, while showing off themajor techniques for lower bounds proofs. Two examples of such textbooks are“<strong>Computer</strong> <strong>Algorithm</strong>s” by Baase <strong>and</strong> Van Gelder [BG00], <strong>and</strong> “Compared toWh<strong>at</strong>?” by Gregory J.E. Rawlins [Raw92]. “Fundamentals of <strong>Algorithm</strong>ics” byBrassard <strong>and</strong> Br<strong>at</strong>ley [BB96] also covers lower bounds proofs.15.9 Exercises15.1 Consider the so-called “algorithm for algorithms” in Section 15.1. Is thisreally an algorithm? Review the definition of an algorithm from Section 1.4.Which parts of the definition apply, <strong>and</strong> which do not? Is the “algorithm foralgorithms” a heuristic for finding a good algorithm? Why or why not?15.2 Single-elimin<strong>at</strong>ion tournaments are notorious for their scheduling difficulties.Imagine th<strong>at</strong> you are organizing a tournament for n basketball teams(you may assume th<strong>at</strong> n = 2 i for some integer i). We will further simplify

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

Saved successfully!

Ooh no, something went wrong!