Mian-Chowla sequence: Difference between revisions

m
→‎{{header|Pascal}}: finished 25000
m (→‎{{header|Pascal}}: small improvement, known where to insert.Show runtime behavier of this implementation)
m (→‎{{header|Pascal}}: finished 25000)
Line 804:
keep sum of all sorted.Memorizing the compare positions speeds up.
<BR>
<pre>const
Calculating runtime to expect.
deltaK = 540250;
<pre>
maxCnt = 25000;
n-> 2x n ~>
Using
average distance between d = mian[n]-mian[n-1] d ~ 4x d
tElem = Uint64;
runtime t-> >10x t. ->
t_n_sum_all = array of tElem; //dynamic array
n mian-chowla[n] avgaverage dist runtime
2700 225432491 195419 43411 ms
250 317739 1270 429 ms// runtime setlength of 2.35 GB ~ 400ms
5400 1613654038 766839 471468 ms
500 2085045 7055 589 ms
</pre>
750 6265086 16632 1053 ms
So calculating mian[25000] = mian[5940*(2**2,0733)]
..
runtime minimum > 10.86**2.0733 *471.5s = 66251 s and round about 2.5 Gbyte for Uint64.
1500 43205712 67697 6669 ms
One or two days should be enough.
..
3000 303314913 264489 65040 ms //2xn -> runtime x9,75
..
6000 2189067236 1019161 719208 ms //2xn -> runtime x11,0
6250 2451223363 1047116 825486 ms
..
12000 15799915996 3589137 8180177 ms //2xn -> runtime x11,3
12250 16737557137 3742360 8783711 ms
12500 17758426186 4051041 9455371 ms
..
24000 115709049568 13738671 99959526 ms //2xn -> runtime x12
24250 119117015697 13492623 103691559 ms
24500 122795614247 14644721 107758962 ms
24750 126491059919 14708578 111875949 ms
25000 130098289096 14414457 115954691 ms //dt = 4078s ->16s/per number
real 1932m34,698s => 1d8h12m35</pre>
<lang pascal>program MianChowla;
//compiling with /usr/lib/fpc/3.2.0/ppcx64.2 -MDelphi -O4 -al "%f"
Line 824 ⟶ 841:
deltaK = 100;
maxCnt = 1000;
{
deltaK = 540;
maxCnt = (5966 DIV deltaK)*deltaK;
*}
type
tElem = Uint32;
Line 859 ⟶ 872:
 
procedure InsertNew_sum(NewValue:NativeUint);
//insertion already knowning the positions
//insertionsort
var
pElem :tpElem;
Line 974 ⟶ 987:
writeln;
END.
{#####
deltaK = 540;
maxCnt = (5966 DIV deltaK)*deltaK;
Allocated memory 70650384
540 2574622 4767 234 ms
1080 17315247 27269 2084 ms
1620 53808559 67542 7876 ms
2160 119743492 121877 20367 ms
2700 225432491 195419 43411 ms
3240 377659559 281283 80801 ms
3780 585851493 384664 137472 ms
4320 853722843 494787 217026 ms
4860 1198603744 637443 328136 ms
5400 1613654038 766839 471468 ms
5940 2124053407 944624 659681 ms
 
real 10m59,682s
}
</lang>
{{Out}}
Anonymous user