Question

In: Computer Science

Algorithm. We divide each of the matrices A and B into 9 submatrices with size n/3...

Algorithm. We divide each of the matrices A and B into 9 submatrices with size n/3 × n/3 each. The matrix C = A × B is obtained by using 25 multiplications and 30 additions of the submatrices. What is the recursive formula of the running time function T(n) of this algorithm? What is the running time of this algorithm (in Θ notation)?

Solutions

Expert Solution

Let a, b, c, d, e, f, g, h, i be the size of n/3 * n/3 submatrices of A.

and, a' , b' , c' , d' , e' , f' , g' , h' , i' be the size of n/3 * n/3 submatrices of B.

A,B,C is the matric of the size of n * n suct that A*B = C.

Given that the matrix C = A*B is obtained by using 25 multiplication and 30 addition of the submatrices ,

therefore the the recursiive formula of the running time function will according to the above method, in which we do 25 multiplications for matrices of size N/3 x N/3 and 30 additions since addition of two matrices takes O(N2) time. So the recursive  formula can be written as

T(N) = 25T(N/3) + o(N2)

The Running time complexity can be calculate by using Master Method which is as following

The master method works only for following type of recurrences that can be transformed to following type.

T(n) = aT(n/b) + f(n) where a >= 1 and b > 1

There are following three cases:
1. If f(n) = Θ(nc) where c < Logba then T(n) = Θ(nLogba)

2. If f(n) = Θ(nc) where c = Logba then T(n) = Θ(ncLog n)

3.If f(n) = Θ(nc) where c > Logba then T(n) = Θ(f(n))

So our Recursion Formula is:  T(N) = 25T(N/3) + o(N2)

where, we can say that ,

a =25 where a>=1

b=3 where b>1

and f(n) = O(N2) which implies that c=2

so let's calculate logba = log325 = log25 / log 3 = 2.93

therefore c < Logba which comes under case 1.

So Time complxity will be ,  T(N) =Θ(nLogba) =Θ(nLog325)

  


Related Solutions

3. Suppose that a divide and conquer algorithm for multiplication of n x n matrices is...
3. Suppose that a divide and conquer algorithm for multiplication of n x n matrices is found such that it requires 6 multiplications and 31 additions of n/2 x n/2 submatrices. Write the recurrence for the running time T(n) of this algorithm and find the order of T(n).
Divide and Conquer (Strassen’s Matrix Multiplication) Given two square matrices A and B of size n...
Divide and Conquer (Strassen’s Matrix Multiplication) Given two square matrices A and B of size n x n each, find their multiplication matrix. Naive Method Following is a simple way to multiply two matrices.                void multiply(int A[][N], int B[][N], int C[][N]) {     for (int i = 0;   i < N; i++) {         for (int j = 0; j < N; j++) {             C[i][j] = 0;             for (int k = 0; k < N; k++) {                 C[i][j] += A[i][k]*B[k][j];             }...
2. Using matrices, create an algorithm that takes a matrix of dimension N x N and...
2. Using matrices, create an algorithm that takes a matrix of dimension N x N and feed it in a spiral shape with the sequential number from 1 to N^2. Then do an algorithm in PSEint
For matrices A ∈ Rn×n and B ∈ Rn×p, prove each of the following statements: (a)...
For matrices A ∈ Rn×n and B ∈ Rn×p, prove each of the following statements: (a) rank(AB) = rank(A) and R(AB) = R(A) if rank(B) = n. (b) rank(AB) = rank(B) and N (AB) = N (B) if rank(A) = n.
Suppose we have a substring of length m and text of size n. Write an algorithm...
Suppose we have a substring of length m and text of size n. Write an algorithm to find out if the substring is present in the text or not. What is the complexity of your algorithm in terms of m and n.
(a) The n × n matrices A, B, C, and X satisfy the equation AX(B +...
(a) The n × n matrices A, B, C, and X satisfy the equation AX(B + CX) ?1 = C Write an expression for the matrix X in terms of A, B, and C. You may assume invertibility of any matrix when necessary. (b) Suppose D is a 3 × 5 matrix, E is a 5 × c matrix, and F is a 4 × d matrix. Find the values of c and d for which the statement “det(DEF) =...
Let A be an integer array of length n. Design a divide and conquer algorithm (description...
Let A be an integer array of length n. Design a divide and conquer algorithm (description and pseudo code) to find the index of an element of the minimum value in the array. If there are several such elements, your algorithm must return the index of the rightmost element. For instance, if A = {0,2,4,5,2,0,3,10}, then the algorithm should return 5, which is the index of the second 0.
for an array A of size N, and A[0] != A[n-1]. devise an efficient algorithm for...
for an array A of size N, and A[0] != A[n-1]. devise an efficient algorithm for find a pair of elements A[i] and A[i+1] such that A[i] != A[i+1]. can you always find such pair and why
Consider a sorting algorithm that combines merge sort and insertion sort algorithm. We still use divide...
Consider a sorting algorithm that combines merge sort and insertion sort algorithm. We still use divide and conquer like merge sort, however when the number of elements in an array is at most k elements (k is a parameter), we stop dividing the elements as the regular merge sort, instead, we call the insertion sort. Assuming we have defined the following two procedures: insertion-sort(A[p..q]) which sort the subarray A[p..q] merge(A[p,q,r]) which merges the sorted subarray A[p..r] and A[r+1..q] Try to...
Why in the formalism of the standard deviation of the population we divide by n and...
Why in the formalism of the standard deviation of the population we divide by n and for the standard deviation of the sample we divide by n-1?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT