Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

5. (14 pts.] Consider the typical matrix-vector multiplication operation: given a (dx d) matrix A(i.c., a squared matrix with d rows and d columns), and

image text in transcribed

5. (14 pts.] Consider the typical matrix-vector multiplication operation: given a (dx d) matrix A(i.c., a squared matrix with d rows and d columns), and a d-dimensional (row) vector I i.e., a vector with d elements; or equivalently, a matrix with d rows and a single column), where d is a positive integer, compute the d-dimensional (row) vector y = Ar. That is, using 0-based indexing, for all i = 0,1,..., d-1, yi= : blijf;, where ajj is the element in the ith row and jth column of matrix A. Consider the following algorithm, MATRIX VECMULT (Algorithm 5), for this operation, assumming that A and I are represented using 2-dimensional and 1- dimensional arrays, respectively, as typically done. The algorithm uses an auxiliary algorithm, VECMULT (Algorithm 6), which takes as input two arrays of numbers, z and I, and a positive integer d, where the size of both z and r is at least d. Assume that the input to this auxiliary algorithm VECMULT (Algorithm 6) is passed by-value. Algorithm 5 MATRIXVECMULT(4,1,d) 1: yt new 1-dim array of d numbers 2: 2 new 1-dim array of d numbers 3: for it to d -1 do for jo to d -1 do 5: z[j] + A[i][j] 6: y[i] + VECMULT(2,2,d) 7: return y Algorithm 6 VECMULT(2,2,d) 1: if d=0 then return 0 2: return z[d - 1] *x[d 1] + VECMULT(2, 1,2 - 1) (a) Provide the tightest characterization possible of the running time and space complexity of the algorithm MATRIX VECMULT (Algorithm 5), using either big-Oh and big-Omega, or simply big-Theta, as a function of the input value d. Time Space (b) Provide the tightest characterization possible of the running time and space complerity of the same algorithm MATRIX VECMULT (Algorithm 5), using either big-Oh and big- Omega, or simply big-Theta, now as a function of the input size n; that is, n characterizes the size of the input to the algorithm as a function of the input value d. Time Space (c) Is this a linear-time algorithm? Please circle your answer and explain briefly but clearly. In addition, if you answered 'No', please clearly state what type of algorithm it is in terms of running time. Yes No (d) Please write, using pseudocode, a linear-time and linear-space algorithm for the same task. 5. (14 pts.] Consider the typical matrix-vector multiplication operation: given a (dx d) matrix A(i.c., a squared matrix with d rows and d columns), and a d-dimensional (row) vector I i.e., a vector with d elements; or equivalently, a matrix with d rows and a single column), where d is a positive integer, compute the d-dimensional (row) vector y = Ar. That is, using 0-based indexing, for all i = 0,1,..., d-1, yi= : blijf;, where ajj is the element in the ith row and jth column of matrix A. Consider the following algorithm, MATRIX VECMULT (Algorithm 5), for this operation, assumming that A and I are represented using 2-dimensional and 1- dimensional arrays, respectively, as typically done. The algorithm uses an auxiliary algorithm, VECMULT (Algorithm 6), which takes as input two arrays of numbers, z and I, and a positive integer d, where the size of both z and r is at least d. Assume that the input to this auxiliary algorithm VECMULT (Algorithm 6) is passed by-value. Algorithm 5 MATRIXVECMULT(4,1,d) 1: yt new 1-dim array of d numbers 2: 2 new 1-dim array of d numbers 3: for it to d -1 do for jo to d -1 do 5: z[j] + A[i][j] 6: y[i] + VECMULT(2,2,d) 7: return y Algorithm 6 VECMULT(2,2,d) 1: if d=0 then return 0 2: return z[d - 1] *x[d 1] + VECMULT(2, 1,2 - 1) (a) Provide the tightest characterization possible of the running time and space complexity of the algorithm MATRIX VECMULT (Algorithm 5), using either big-Oh and big-Omega, or simply big-Theta, as a function of the input value d. Time Space (b) Provide the tightest characterization possible of the running time and space complerity of the same algorithm MATRIX VECMULT (Algorithm 5), using either big-Oh and big- Omega, or simply big-Theta, now as a function of the input size n; that is, n characterizes the size of the input to the algorithm as a function of the input value d. Time Space (c) Is this a linear-time algorithm? Please circle your answer and explain briefly but clearly. In addition, if you answered 'No', please clearly state what type of algorithm it is in terms of running time. Yes No (d) Please write, using pseudocode, a linear-time and linear-space algorithm for the same task

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Fundamentals Study Guide

Authors: Dr. Sergio Pisano

1st Edition

B09K1WW84J, 979-8985115307

More Books

Students also viewed these Databases questions

Question

What is Change Control and how does it operate?

Answered: 1 week ago

Question

How do Data Requirements relate to Functional Requirements?

Answered: 1 week ago