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.

46 Chap. 2 Mathematical PreliminariesFigure 2.3 A two-coloring for the regions formed by three lines in the plane.n − 1 lines. Unfortunately, the regions newly split by the nth line violatethe rule for a two-coloring. Take all regions on one side of the nth line <strong>and</strong>reverse their coloring (after doing so, this half-plane is still two-colored).Those regions split by the nth line are now properly two-colored, Becausethe part of the region <strong>to</strong> one side of the line is now black <strong>and</strong> the region<strong>to</strong> the other side is now white. Thus, by mathematical induction, the entireplane is two-colored.✷Compare the proof of Theorem 2.7 with that of Theorem 2.5. For Theorem 2.5,we <strong>to</strong>ok a collection of stamps of size n − 1 (which, by the induction hypothesis,must have the desired property) <strong>and</strong> from that “built” a collection of size n thathas the desired property. We therefore proved the existence of some collection ofstamps of size n with the desired property.For Theorem 2.7 we must prove that any collection of n lines has the desiredproperty. Thus, our strategy is <strong>to</strong> take an arbitrary collection of n lines, <strong>and</strong> “reduce”it so that we have a set of lines that must have the desired property becauseit matches the induction hypothesis. From there, we merely need <strong>to</strong> show that reversingthe original reduction process preserves the desired property.In contrast, consider what would be required if we attempted <strong>to</strong> “build” from aset of lines of size n − 1 <strong>to</strong> one of size n. We would have great difficulty justifyingthat all possible collections of n lines are covered by our building process. Byreducing from an arbitrary collection of n lines <strong>to</strong> something less, we avoid thisproblem.This section’s final example shows how induction can be used <strong>to</strong> prove that arecursive function produces the correct result.

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

Saved successfully!

Ooh no, something went wrong!