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.

564 Chap. 17 Limits <strong>to</strong> ComputationProblem A:ITransform 1I’Problem BSLN’Transform 2SLNFigure 17.2 The general process for reduction shown as a “blackbox” diagram.Asymp<strong>to</strong>tically faster (but more complicated) algorithms are known, but none is sofast as <strong>to</strong> be in O(n).Next we ask the question: Is squaring an n-digit number as difficult as multiplyingtwo n-digit numbers? We might hope that something about this special casewill allow for a faster algorithm than is required by the more general multiplicationproblem. However, a simple reduction proof serves <strong>to</strong> show that squaring is “ashard” as multiplying.The key <strong>to</strong> the reduction is the following formula:X × Y = (X + Y )2 − (X − Y ) 2.4The significance of this formula is that it allows us <strong>to</strong> convert an arbitrary instanceof multiplication <strong>to</strong> a series of operations involving three addition/subtractions(each of which can be done in linear time), two squarings, <strong>and</strong> a division by 4.Note that the division by 4 can be done in linear time (simply convert <strong>to</strong> binary,shift right by two digits, <strong>and</strong> convert back).This reduction shows that if a linear time algorithm for squaring can be found,it can be used <strong>to</strong> construct a linear time algorithm for multiplication.

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

Saved successfully!

Ooh no, something went wrong!