2. a. Consider the definition-based algorithm for adding two n × n matrices. What is its basic operation? How many times is it performed as a function of the matrix order n? As a function of the total number of elements in the input matrices?
b. Answer the same questions for the definition-based algorithm for matrix multiplication.
a)
Definition-based algorithm for adding two n × n matrices:
b)
Definition-based algorithm for matrix multiplication:
In summary, for matrix addition, the basic addition operation is performed n^2 times as a function of the matrix order n and 2n2 times as a function of the total number of elements in the input matrices. For matrix multiplication, the basic multiplication and addition operations are performed n(n-1) times as a function of the matrix order n and 2n2 times as a function of the total number of elements in the input matrices.