I have a loop that looks something like the one shown below. I'm interested in finding Big O for this loop structure.
for i = 1 to n { // assume that n is input size
...
for j = 1 to 2 * i {
...
k = j;
while (k >= 0) {
...
k = k - 1;
}
}
}
From what I can gather is:
- Outer-most loop runs 'n' times
- The second loop runs '2n' times (assuming increment size is 1)
- Inner-most loop runs '2n' times
So should the Big O of n be O(n^3) or will it be something different?
A concrete link to such problems and their solutions will be appreciated.