Say I have a snippet of code:
k = 5
i, j = 0
for i -> n
if i == k
for j -> k
/* do something */
end for
k = k * 4/3
end if
/* do something */
end for
I can tell that the algorithm is worse than n but can't be worse than n^2. In fact it seems like it would be less than n log (n). Though I admit these are just guesses I'm making. Is there any methodology to figuring out what the big theta is for such algorithms?
for i->n
mean? And did you check our reference question? – David Richerby Sep 07 '15 at 08:00