Give a BigO estimate for the number of operations used in th
Give a Big-O estimate for the number of operations used in this algorithm, where an operation is an addition or a multiplication.
t:=0
for i=1 to 3
for j:=1 to 4
t:= t+ ij
Solution
t + ij will do two operations per loop iteration (one multiplication and one addition).
The j-for loop will execute t + ij 4 times.
The i-for loop will execute 3 times.
Since the j-for loop is executed for every iteration for the i-for loop, then we have 2 · 3 · 4 = 24
total operations.
Therefore, the algorithm is O(1)
