- Published on
The Algorithm Design Manual (3rd) Exercise Solution 'E2-15'
Table of Contents
Introduction
This series is my solutions for algorithm exercises in'The Algorithm Design Manual' 3rd edition.
It's my solutions, not model answers, so if you find some mistakes or more sophisticated solutions, please post in comment area below.
Repository
Exercise 2-15
Question
Suppose you have algorithms with the five running times listed below. (Assume these are the exact running times.) How much slower do each of these algorithms get when you (a) double the input size, or (b) increase the input size by one?
(a) (b) (c) (d) (e)
Solution
Algorithm(a)
Size Change - double
Ans. Increased by a factor of 4
Size Change - by one
Ans. Increased by
Algorithm(b)
Size Change - double
Ans. Increased by a factor of 8
Size Change - by one
Ans. Increased by
Algorithm(c)
Size Change - double
Same as Algorithm(a)
Size Change - by one
How to think is the same as that for Algorithm(a).
Ans. Increased by
Algorithm(d)
Size Change - double
Ans. The Running time is doubled and an additional is added.
Size Change - by one
Let's think of the range of
So,
Multiplying and Adding to each expressions above introduces:
Ans. Increased by the amount between and .
Algorithm(b)
Size Change - double
Ans. Increased to be the square of the original running time.
Size Change - by one
Ans. Running times is doubled.