big o - Time complexity of the algorithm by counting the comparisons and we need to give a big o estimate -
:= 1 m // loop 1 j:= 1 n // loop 2 cij := 0 q := 1 k // loop 3 cij := cij + aiqbqj return c
note within loop 2, there k + 1
assignments, while j
loops 1
n
, there in total n * (k + 1)
assignments.
adding on top of that, while i
loops 1
m
there in total m * n * (k + 1)
assignments.
so time complexity of code o(m * n * (k + 1)) = o(mnk)
.
Comments
Post a Comment