/*! This file is auto-generated */ .wp-block-button__link{color:#fff;background-color:#32373c;border-radius:9999px;box-shadow:none;text-decoration:none;padding:calc(.667em + 2px) calc(1.333em + 2px);font-size:1.125em}.wp-block-file__button{background:#32373c;color:#fff;text-decoration:none} Q27E The聽square of a matrix A is its... [FREE SOLUTION] | 91影视

91影视

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?

鈥淯se a divide-and-conquer approach as in Strassen鈥檚 algorithm, except that instead of getting 7 subproblems of size n2, we now get 5 subproblems of size n2 thanks to part (a). Using the same analysis as in Strassen鈥檚 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) .

  1. Given two n x n matrices A and B, show that the matrix AB + BA can be computed in time 3S(n) + O(n2 ) .
  2. Given two n x n matrices X and Y, define the 2n x 2n matrices A and B,L as follows:
    A=X000andB=0Y00
    What is AB + BA, in terms of X and Y?
  3. Using (i) and (ii), argue that the product XY can be computed in time 3S(2n) + O(n2 ). Conclude that matrix multiplication takes time O(nc ).

Short Answer

Expert verified
  1. mnopmnop=m2+non(m+p)0(m+p)no+p2,5
  2. The suggested algorithm has insufficient run time to perform the square of the matrix.

  3. (i) Given matrix can be computed in 3S(n) +O(n2 )
    (ii) AB+BA=0XY00
    (iii) The product XYneeds only 2S (2n) + O(n2 )computation time and the matrix multiplication takes O(nc)time.

Step by step solution

01

Number of multiplications required to compute the square of matrix:

Consider the 2 x 2 matrix, mnop,

Compute the square of the above matrix,

mnopmnop=m2+non(m+p)0(m+p)no+p2

In the computation, the multiplications involved are m2, n (m + p), o (m + p), p2 , and no.

Therefore, the five multiplications are sufficient to calculate the square of 2 x 2 matrix.

02

What is wrong with the given algorithm

(b)

A matrix squaring problem of size n xn has 5 sub-problems of size n2. The half of the sub-problems (that is, three of the five sub-problems) are engaged in the product of n2n2matrices, according to the divide and conquer approach. There are five sub-problems in all, each of which is n2 in size. Each sub-operation of a problem has been denoted by T Because the two sets of matrices are divided and conquered, this procedure will take O(n2) time to run. As a result, this method does not execute in "O(n O(nlog23) time.

As a result, the suggested algorithm's running time is insufficient for computing the square of a n x n matrix.

03

show that the matrix AB + BA can be computed in time 3S(n) + O(n2).

(c)

i.

Consider the two n x n matrices, A and B .

Calculate, AB + BA as follows,

AB+BA=(A+B)(A+B)-AA-BB ,

The computation involves three squared terms, that can be computed in 3S(n) times. The other arithmetic operations can be computed in O(n2) time.

Therefore, the computation of AB + BA can be computed in 3S(n) + O(n2) time.

04

show the matrix AB + BA in terms of X and Y 

(c)

ii.

Consider the two n x n matrices, A and B .

A=X000,B=0Y00AB+BA=X000+0Y00X000+0Y00-X000+X0000Y00+0Y00=0XY00 ,

Therefore, the representation of AB + BA , in terms of X and Y is0XY00

05

show the matrix AB + BA in terms of X and Y 

(c)

iii.

Consider the product of XY as follows,

0XY00=XY00XY00-X000X000-0Y000Y00

Since, 0Y000Y00=0,

The product will be,0XY00=XY00XY00-X000X000

The product has two squares and a arithmetic opertation.

Therefore,The product XYneeds only 2S(2n) + O(n2)computation time and the matrix multiplication takes O(nc)time.

Unlock Step-by-Step Solutions & Ace Your Exams!

  • Full Textbook Solutions

    Get detailed explanations and key concepts

  • Unlimited Al creation

    Al flashcards, explanations, exams and more...

  • Ads-free access

    To over 500 millions flashcards

  • Money-back guarantee

    We refund you if you fail your exam.

Over 30 million students worldwide already upgrade their learning with 91影视!

One App. One Place for Learning.

All the tools & learning materials you need for study success - in one app.

Get started for free

Most popular questions from this chapter

A kway merge operation. Suppose you have ksorted arrays, each with nelements, and you want to combine them into a single sorted array ofkn elements.

(a)Here鈥檚 one strategy: Using the merge procedure from Section 2.3, merge the first two arrays, then merge in the third, then merge in the fourth, and so on. What is the time complexity of this algorithm, in terms of kand n?

(b) Give a more efficient solution to this problem, using divide-and-conquer.

A binary tree is full if all of its vertices have either zero or two children. Let Bndenote 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 B3, B5, and B7. Why have we left out even numbers of vertices, like B4?

(b) For general n, derive a recurrence relation for Bn.

(c) Show by induction that Bnis (2n).

An array A [1...n] is said to have a majority element if more than half of its entries are the same. Given an array, the task is to design an efficient algorithm to tell whether the array has a majority element, and, if so, to find that element. The elements of the array are not necessarily from some ordered domain like the integers, a A2 nd so there can be no comparisons of the form 鈥渋s A[i]>A[j]?鈥. (Think of the array elements as GIF files, say.) However you can answer questions of the form: 鈥渋s ..?鈥 in constant time.

(a) Show how to solve this problem in O(nlog n) time. (Hint: Split the array A into two arrays A1 and of half the size. Does knowing the majority elements of A1 and A2 help you figure out the majority element of A? If so, you can use a divide-and-conquer approach.)

(b) Can you give a linear-time algorithm? (Hint: Here鈥檚 another divide-and-conquer approach:

  • Pair up the elements of A arbitrarily, to get n/2 pairs
  • Look at each pair: if the two elements are different, discard both of them; if they are the same, keep just one of them
    Show that after this procedure there are at most n/2 elements left, and that they have a majority element if A does.)

Question: Use the divide-and-conquer integer multiplication algorithm to multiply the two binary integers 10011011and10111010 and .

In Section 1.2.3, we studied Euclid鈥檚 algorithm for computing the greatest common divisor (gcd) of two positive integers: the largest integer which divides them both. Here we will look at an alternative algorithm based on divide-and-conquer.

(a) Show that the following rule is true.

gcd(a,b)={2gcd(a2,b2)ifa,bareevengcd(ab2)ifaisodd,bisevengcd(a-b2,b)ifa,bareodd

(b) Give an efficient divide-and-conquer algorithm for greatest common divisor.

(c) How does the efficiency of your algorithm compare to Euclid鈥檚 algorithm if a and b are n-bit -bit integers? (In particular, since n might be large you cannot assume that basic arithmetic operations like addition take constant time.)

See all solutions

Recommended explanations on Computer Science Textbooks

View all explanations

What do you think about this solution?

We value your feedback to improve our textbook solutions.

Study anywhere. Anytime. Across all devices.