Chapter 2: Q2E (page 83)
Show that for any positive integers n and any base b , there must some power of b lying in the range .
Short Answer
To show that some power of b falls in the range of
Chapter 2: Q2E (page 83)
Show that for any positive integers n and any base b , there must some power of b lying in the range .
To show that some power of b falls in the range of
All the tools & learning materials you need for study success - in one app.
Get started for freeSection 2.2 describes a method for solving recurrence relations which is based on analyzing the recursion tree and deriving a formula for the work done at each level. Another (closely related) method is to expand out the recurrence a few times, until a pattern emerges. For instance, let’s start with the familiar . Think of as being role="math" localid="1658920245976" for some constant , so: . By repeatedly applying this rule, we can bound in terms of , then , then , and so on, at each step getting closer to the value of we do know, namely .
.
.
.
A pattern is emerging... the general term is
Plugging in , we get .
(a)Do the same thing for the recurrence . What is the general th term in this case? And what value of should be plugged in to get the answer?(b) Now try the recurrence , a case which is not covered by the master theorem. Can you solve this too?
In Section 2.1 we described an algorithm that multiplies two n-bit binary integers x and y in time , where . Call this procedure fast multiply (x,y).
(a) We want to convert the decimal integer (a 1 followed by n zeros) into binary. Here is the algorithm (assume n is a power of 2):
function pwr2bin(n)
if n = 1: return
else:
z= ???
return fastmultiply(z,z)
Fill in the missing details. Then give a recurrence relation for the running time of the algorithm, and solve the recurrence.
(b) Next, we want to convert any decimal integer x with n digits (where n is a power of 2) into binary. The algorithm is the following:
function dec2bin(x)
if n=1: return binary [ x ]
else:
split x into two decimal numbers with n/2 digits each
return ???
Here binary [.] is a vector that contains the binary representation of all one-digit integers. That is, binary role="math" localid="1659333641173" , binary , up to binary . Assume that a lookup in binary takes 0(1) time. Fill in the missing details. Once again, give a recurrence for the running time of the algorithm, and solve it.
Question: Solve the following recurrence relations and give a bound for each of them.
Practice with the fast Fourier transform.
(a) What is the FFT of (1,0,0,0)? What is the appropriate value of in this case? And of which sequence is (1,0,0,0)the FFT?
(b)Repeat for (1,0,1,-1).
You are given an array of elements, and you notice that some of the elements are duplicates; that is, they appear more than once in the array. Show how to remove all duplicates from the array in time .
What do you think about this solution?
We value your feedback to improve our textbook solutions.