Running Times
The running time T(n) of an algorithm is the number of primitive operations performed as a function of the "input size" n.
// A is a square 2-dimensional array
SUM(A){
row = number of rows of A
col = number of columns of A
sum = 0
for i = 1...row
for j = 1...col
sum = sum + A[i][j]
end
end
return sum
}
// C is a calendar represented as a 2-dimensional array with 12 rows
// Each row has a different length
// L is an array of length 12 that indicates the number of columns in each row
COUNT_WORK_DAYS(C, L){
sum = 0
for i = 1...12
numDays = L[i]
for j = 1...numDays
if C[i][j] is a work day
sum = sum + 1
end
end
end
return sum
}