Solving More Complex Large O

So, I know from memory that the for loop looks like this:

for( int i = 0; i > N; i++) 

      

Will have O(N)

, and for each inner loop you add, you simply multiply it by N --

, assuming it is the same for a loop with only a different start. 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 will be lnN

and the second will N

, so it O(NlnN)

will be the answer. But I don't want to memorize these big O

, I want to know how to actually calculate them manually, but how to trace it back to the given N. Can someone please show me some process on how to do this? I've watched 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 it big O

, I can crash

+3


source to share





All Articles