I'm not exactly sure how to come up with a function for the running time of an algorithm...
In class, we found the upper bound of the following to be n((nx+y) + z) + w where nx+y is lines 5-7, z is lines 2-4 and 8-9, and w is the final exit.
(I know it's not in python...)
Quote:
IS (int[] A) {
....int i = 1
....while (i < A.length()) {
........t = A[i];
........int j = i;
........while (j > 0 && A[j-1] > t) {
............A[j] = A[j-1];
............j = j - 1;
........}
........A[j] = t
........i = i + 1
....}
}
I can see how that equation was come up with but I don't know how to find something similar for this:
Quote:
if A[0][0] < -100 or A[0][0] > 100:
....for i in range(n):
........for j in range(n):
............for k in range(j):
................for p in range(i):
....................C[i][j] = (i + j)*A[i][j] + (k + p)*B[k][j]
else:
....for i in range(n):
........for j in range(n):
............for k in range(j):
................C[i][j] = (i + j)*A[i][j] + k*B[k][j]
Please help 