Question 7
Consider the following algorithm:
Input: Two matrices A and B both of size n x n
1. Initialize C to be a matrix of size n x n whose entries are all 0
2. For i from 1 to n:
3. For j from 1 to n:
4. If Ai, j ≠ Bi, j:
5. Ci, j = Ai, j x Bi, j
6. Output C
Determine the time function of this algorithm. To explain, state number of time units or iterations in each line.
Students succeed in their courses by connecting and communicating with an expert until they receive help on their questions
Consult our trusted tutors.