Big O Help

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

tenniskev18

Thread Starter
Joined
May 11, 2007
Messages
18
Hey guys/girls.

I am having issues determining the Big O for this set of loops.

for(int i =0; i < n; i++)
for(int j = 0; j < i*i; j++)
for(int k = 0; k < j; k++)
sum++;

I know that the two outmost loop is O(n) and the middle loop is O(n^2), but I cant quiet determine what the third loops big O is... When I run the code I am getting 162 as the number of iterations.

Also:

for(int i = 1; i < n; i++)
for(int j = 1; j < i*i; j++)
if(j%i == 0)
for(int k = 0; k<j; k++)
sum++;

The outmost loop is n, the middle is n^2, but I cant figure out what the last loops big O is.

Anyone have any suggestions or comments?

Thanks
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Members online

Top