CSC300: 2D Square [3/19] Previous pageContentsNext page

01
02
03
04
05
    for (long i = 1; i <= N; i = i+1) {
      for (long j = 1; j <= N; j = j+1) {
        result = result+1;
      }
    }

Output

01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 
02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 
03 03 03 03 03 03 03 03 03 03 03 03 03 03 03 03 
04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 
05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 
06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 
07 07 07 07 07 07 07 07 07 07 07 07 07 07 07 07 
08 08 08 08 08 08 08 08 08 08 08 08 08 08 08 08 
09 09 09 09 09 09 09 09 09 09 09 09 09 09 09 09 
10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 
11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 
12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 
13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 
14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 
15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 
16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 
Elapsed count f(          512):          262,144:      4.000 [     0.003 :      0.750]
Elapsed count f(        1,024):        1,048,576:      4.000 [     0.001 :      0.333]
Elapsed count f(        2,048):        4,194,304:      4.000 [     0.006 :      6.000]
Elapsed count f(        4,096):       16,777,216:      4.000 [     0.032 :      5.333]
Elapsed count f(        8,192):       67,108,864:      4.000 [     0.056 :      1.750]
Elapsed count f(       16,384):      268,435,456:      4.000 [     0.152 :      2.714]
Elapsed count f(       32,768):    1,073,741,824:      4.000 [     0.546 :      3.592]
Elapsed count f(       65,536):    4,294,967,296:      4.000 [     2.228 :      4.081]
Elapsed count f(      131,072):   17,179,869,184:      4.000 [     9.405 :      4.221]
Elapsed count f(      262,144):   68,719,476,736:      4.000 [    35.069 :      3.729]
Elapsed count f(      524,288) aborted execution after a minute or so
Elapsed count f(    1,048,576) aborted execution after a minute or so
Elapsed count f(    2,097,152) aborted execution after a minute or so
Elapsed count f(    4,194,304) aborted execution after a minute or so
Elapsed count f(    8,388,608) aborted execution after a minute or so
Elapsed count f(   16,777,216) aborted execution after a minute or so
Elapsed count f(   33,554,432) aborted execution after a minute or so
Elapsed count f(   67,108,864) aborted execution after a minute or so
Elapsed count f(  134,217,728) aborted execution after a minute or so
Elapsed count f(  268,435,456) aborted execution after a minute or so
Elapsed count f(  536,870,912) aborted execution after a minute or so
Elapsed count f(1,073,741,824) aborted execution after a minute or so
Elapsed count f(2,147,483,648) aborted execution after a minute or so

This is quadratic: ~ N^2

Previous pageContentsNext page