This preview shows page 1. Sign up to view the full content.
Unformatted text preview: for (int j=i; j<N; j++) // key difference c[i][j] = a[i][j] + b[i][j]; t+=c[i][j]; { } cout << t << endl; { } The inner loop executes "Ni" times now instead of N times, so the time it takes will be C*(Ni) Each execution of the loop takes less time as "i"increases. The math is roughly: We ignore constants of proportionality, so essentially this is still N^2 How to calculate growth patterns: Suppose we have 2 NxN matricies (same size) A and B, and want to sum them into a new NxN matrix C. We need to do N^2 additions, and we can see this very easily. However, let's come up with that N^2 number using a generalized technique. As we go we'll also calculate the sum of each row of the resultant matrix and display it. CS Page 1...
View
Full
Document
This note was uploaded on 04/02/2012 for the course COMPUTER S 32 taught by Professor Smallberg during the Winter '12 term at UCLA.
 Winter '12
 Smallberg
 Computer Science

Click to edit the document details