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...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Sec. 16.3 Numerical <strong>Algorithm</strong>s 545encountering the worst case decreases geometrically. Thus, the Skip List illustratesa tension between the theoretical worst case (in this case, Θ(n) for a Skip Lis<strong>to</strong>peration), <strong>and</strong> a rapidly increasing probability of average-case performance ofΘ(log n), that characterizes probabilistic data structures.16.3 Numerical <strong>Algorithm</strong>sThis section presents a variety of algorithms related <strong>to</strong> mathematical computationson numbers. Examples are activities like multiplying two numbers or raising anumber <strong>to</strong> a given power. In particular, we are concerned with situations wherebuilt-in integer or floating-point operations cannot be used because the values beingoperated on are <strong>to</strong>o large. Often, similar operations are applied <strong>to</strong> polynomials ormatrices.Since we cannot rely on the hardware <strong>to</strong> process the inputs in a single constanttimeoperation, we are concerned with how <strong>to</strong> most effectively process the operation<strong>to</strong> minimize the time cost. This begs a question as <strong>to</strong> how we can apply our normalmeasures of asymp<strong>to</strong>tic cost in terms of growth rates on input size. First, what is aninstance of addition or multiplication? Each value of the oper<strong>and</strong>s yields a differentproblem instance. And what is the input size when multiplying two numbers? If weview the input size as two, then any non-constant-time algorithm has a growth ratethat is infinitely high compared <strong>to</strong> the growth of the input. This makes no sense,especially in light of the fact that we know from grade school arithmetic that addingor multiplying numbers does seem <strong>to</strong> get more difficult as the value of the numbersinvolved increases. In fact, we know from st<strong>and</strong>ard grade school algorithms thatthe cost of st<strong>and</strong>ard addition is linear on the number of digits being added, <strong>and</strong>multiplication has cost n × m when multiplying an m-digit number by an n-digitnumber.The number of digits for the oper<strong>and</strong>s does appear <strong>to</strong> be a key considerationwhen we are performing an algorithm that is sensitive <strong>to</strong> input size. The numberof digits is simply the log of the value, for a suitable base of the log. Thus, for thepurpose of calculating asymp<strong>to</strong>tic growth rates of algorithms, we will consider the“size” of an input value <strong>to</strong> be the log of that value. Given this view, there are anumber of features that seem <strong>to</strong> relate such operations.• Arithmetic operations on large values are not cheap.• There is only one instance of value n.• There are 2 k instances of length k or less.• The size (length) of value n is log n.

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

Saved successfully!

Ooh no, something went wrong!