I'm studying for a test and saw this question , so I did the following, is it correct?
the while loop runs at O(log3n).
the for loop runs at about O((n-(some math))*log2n) so because I have the minus symbol which is linear, I say that the whole method runs at O(nlogn), unless I'm wrong and it's something like
O((n-(n/log3n))*log2n) <- not exactly but quite, can't really figure it out.
is the minus linear here or not? if not what is the correct bigO?
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();
}
}