So I know from memory that a for loop that looks like:
for( int i = 0; i > N; i++)
Will have an O(N)
and for every inner loop added you just multiply it by N --
assuming it's the same for loop with just a different initial. My question is,
for a loop like
for( int i = 0; i < N; i *= 2)
for( int j = 0; j < N; j++)
I know from memory that the first loop would be lnN
and the second would be N
so O(NlnN)
is the answer. But I don't want to memorize these big O
's, I want to know how to actually compute them by hand, iow how to trace it with a given N. Could someone please show me some process on how to do this? I've looked at slideshows from college lectures, but they usually do basic loops. Thanks for the help and guidance!
I can trace it and find the iterations, but when it comes to actually getting Big O
is where I crash