Chapter 2: Q1E (page 83)
Question: Use the divide-and-conquer integer multiplication algorithm to multiply the two binary integers and .
Short Answer
Multiplication of is: 111000010011110
Chapter 2: Q1E (page 83)
Question: Use the divide-and-conquer integer multiplication algorithm to multiply the two binary integers and .
Multiplication of is: 111000010011110
All the tools & learning materials you need for study success - in one app.
Get started for freeA binary tree is full if all of its vertices have either zero or two children. Let denote the number of full binary trees with n vertices. (a)By drawing out all full binary trees with 3, 5, or 7 vertices, determine the exact values of , , and . Why have we left out even numbers of vertices, like ?
(b) For general n, derive a recurrence relation for .
(c) Show by induction that is .
The Hadamard matrices are defined as follows:
localid="1658916810283"
Show that if is a column vector of lengthlocalid="1658916598888" , then the matrix-vector product localid="1658916618774" can be calculated using localid="1658916637767" operations. Assume that all the numbers involved are small enough that basic arithmetic operations like addition and multiplication take unit time.
Thesquare of a matrix A is its product with itself, AA.
(a) Show that five multiplications are sufficient to compute the square of a 2 x 2 matrix.
(b) What is wrong with the following algorithm for computing the square of an n x n matrix?
“Use a divide-and-conquer approach as in Strassen’s algorithm, except that instead of getting 7 subproblems of size , we now get 5 subproblems of size thanks to part (a). Using the same analysis as in Strassen’s algorithm, we can conclude that the algorithm runs in time O (nc) .”
(c) In fact, squaring matrices is no easier than matrix multiplication. In this part, you will show that if n x n matrices can be squared in time S(n) = O(nc), then any two n x n matrices can be multiplied in time O(nc) .
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 this problem we will develop a divide-and-conquer algorithm for the following geometric task.
CLOSEST PAIRInput: A set of points in the plane,
Output: The closest pair of points: that is, the pair for which the distance between and , that is,
,
is minimized.
For simplicity, assume that n is a power of two, and that all the x-coordinates role="math" localid="1659237354869" are distinct, as are the y-coordinates.
Here’s a high-level overview of the algorithm:
.Find a value for which exactly half the points have , and half have . On this basis, split the points into two groups, L and R.
• Recursively find the closest pair in L and in R. Say these pairs are and with distances and respectively. Let d be the smaller of these two distances.
• It remains to be seen whether there is a point in Land a point in R that are less than distance dapart from each other. To this end, discard all points with or and sort the remaining points by y-coordinate.
• Now, go through this sorted list, and for each point, compute its distance to the seven subsequent points in the list. Let be the closest pair found in this way.
• The answer is one of the three pairs role="math" localid="1659237951608" , whichever is closest.
(a) In order to prove the correctness of this algorithm, start by showing the following property: any square of size in the plane contains at most four points of L.
(b) Now show that the algorithm is correct. The only case which needs careful consideration is when the closest pair is split between L and R.
(c) Write down the pseudocode for the algorithm, and show that its running time is given by the recurrence:
Show that the solution to this recurrence is .
(d) Can you bring the running time down to ?
What do you think about this solution?
We value your feedback to improve our textbook solutions.