Efficiency of nested Loop

Posted by didxga on Stack Overflow See other posts from Stack Overflow or by didxga
Published on 2010-03-31T06:06:03Z Indexed on 2010/03/31 6:13 UTC
Read the original article Hit count: 474

Filed under:

See the following snippet:

        //first nested loops
       for(int i=0;i<10;i++) {
        for(int j=1;j<1000000;j++) {
            //do some stuff
        }
    }
            //second nested loops
       for(int i=0;i<1000000;i++) {
        for(int j=1;j<10;j++) {
            //do some stuff
        }
    }

I am wondering why the first nested loops is running slower than the second one?

Regards!

© Stack Overflow or respective owner

Related posts about nested-loops