Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The first picture is the transposeMatrix(A) algorithm. Ive done Part 1 and 2 but cannot figure out the questions in the second picture. Consider the
The first picture is the transposeMatrix(A) algorithm. Ive done Part 1 and 2 but cannot figure out the questions in the second picture.
Consider the problem to compute the transpose AT of an n x n matrix A. Consider the pseudocode to compute the transpose of an n x n matrix A transposeMatrix(A) for = | ton for j = / to j-| Il swap A[i] [i] and buffer = A[i] Ali Gil. = A[i] [i. Al [i] = buffer C) (16 points) Swap Action In this case, we count the number of swaps A[i] [i] >A[] [i]. One swap is performed by the three assignments in Lines 4- 6. Answer the following questions to determine the total number of swaps performed by the algorithm transposeMatrix(A). a. Let us calls the number of swaps for a given value of j. Fill in this table: n-1 b. Express the function f(n) that represents the overall total number of swaps during the execution of transposeMatrix(A). c. The function f(n) grows like which function? D) (6 points) Compare the functions f.(n), fon), and f(n) and discuss their "growth. IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII E) (6 points) Space complexity: answer the following questions. Is this algorithm is in-place? What is its space complexity? How does its space complexity "grow"? Consider the problem to compute the transpose AT of an n x n matrix A. Consider the pseudocode to compute the transpose of an n x n matrix A transposeMatrix(A) for = | ton for j = / to j-| Il swap A[i] [i] and buffer = A[i] Ali Gil. = A[i] [i. Al [i] = buffer C) (16 points) Swap Action In this case, we count the number of swaps A[i] [i] >A[] [i]. One swap is performed by the three assignments in Lines 4- 6. Answer the following questions to determine the total number of swaps performed by the algorithm transposeMatrix(A). a. Let us calls the number of swaps for a given value of j. Fill in this table: n-1 b. Express the function f(n) that represents the overall total number of swaps during the execution of transposeMatrix(A). c. The function f(n) grows like which function? D) (6 points) Compare the functions f.(n), fon), and f(n) and discuss their "growth. IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII E) (6 points) Space complexity: answer the following questions. Is this algorithm is in-place? What is its space complexity? How does its space complexity "growStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started