Tuesday, May 8, 2012

Which one is faster ?

Just found something interesting !!

Problem – 1

for(i=1 ; i<=10000 ; i++){
    for(j=1 ; j<=10 ; j++){
        // Compute A
    }  
}


Problem – 2

for(j=1 ; j<=10 ; j++){
    for(i=1 ; i<=10000 ; i++){
        // Compute A
    }
}


Which one is faster ? Are they both same ?

** Compute A for both takes same time

No comments:

Post a Comment