Tricky Big-O complexity

Posted by timeNomad on Stack Overflow See other posts from Stack Overflow or by timeNomad
Published on 2010-06-06T12:54:01Z Indexed on 2010/06/06 13:02 UTC
Read the original article Hit count: 316

Filed under:
|
public void foo (int n, int m)
{
    int i = m;
    while (i > 100)
        i = i/3;
    for (int k=i ; k>=0; k--)
    {
        for (int j=1; j<n; j*=2)
            System.out.print(k + "\t" + j);
        System.out.println();
    }
}

I figured the complexity would be O(logn).
That is as a product of the inner loop, the outer loop -- will never be executed more than 100 times, so it can be omitted.

What I'm not sure about is the while clause, should it be incorporated into the Big-O complexity? For very large i values it could make an impact, or arithmetic operations, doesn't matter on what scale, count as basic operations and can be omitted?

© Stack Overflow or respective owner

Related posts about homework

Related posts about big-o