Chapter 2: Q26E (page 88)
Professor F. Lake tells his class that it is asymptotically faster to square an -bit integer than to multiply two n-bit integers. Should they believe him?
Short Answer
No, the statement of Professor F. Lake is wrong.
Chapter 2: Q26E (page 88)
Professor F. Lake tells his class that it is asymptotically faster to square an -bit integer than to multiply two n-bit integers. Should they believe him?
No, the statement of Professor F. Lake is wrong.
All the tools & learning materials you need for study success - in one app.
Get started for freeIn justifying our matrix multiplication algorithm (Section 2.5), we claimed the following block wise property: if X and Y are n matrices, and
,
where A,B,C,D,E,F,G, and H are sub-matrices, then the product XY can be expressed in terms of these blocks:
Prove this property.
Question: On page 66 there is a high-level description of the quicksort algorithm.
(a) Write down the pseudocode for quicksort.
(b) Show that its worst - case running time on an array of size n is .
(c) Show that its expected running time satisfies the recurrence relation.
Then, show that the solution to this recurrence is .
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.
In our median-finding algorithm (Section 2.4), a basic primitive is the split operation, which takes as input an array S and a value V and then divides S into three sets: the elements less than V , the elements equal to V , and the elements greater than V . Show how to implement this split operation in place, that is, without allocating new memory.
Given a sorted array of distinct integers , you want to find out whether there is an index for which . Give a divide-and-conquer algorithm that runs in time .
What do you think about this solution?
We value your feedback to improve our textbook solutions.