Monday, 9 September 2013

Big O of this code

Big O of this code

I am doing the exercise of Skiena's book on algorithms and I am stuck in
this question:
I need to calculate the big O of the following algorithm:
function mystery()
r=0
for i=1 to n-1 do
for j=i+1 to n do
for k=1 to j do
r=r+1
Here, the big O of the outermost loop will be O(n-1) and the middle loop
will be O(n!). Please tell me if I am wrong here.
I am not able to calculate the big O of the innermost loop.
Can anyone please help me with this?

No comments:

Post a Comment