Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,34 @@
func QuickSelect(List, Len, K);
int List, Len, K;
int Px, Pv, Last, I, J, T;
[loop [\\partition
Px:= Len/2;
Pv:= List(Px);
Last:= Len-1;
T:= List(Px); List(Px):= List(Last); List(Last):= T;
I:= 0;
for J:= 0 to Last-1 do
[if List(J) < Pv then
[T:= List(I); List(I):= List(J); List(J):= T;
I:= I+1;
];
];
\\select
if I = K then return Pv;
if K < I then Len:= I
else [T:= List(I); List(I):= List(Last); List(Last):= T;
List:= @List(I+1);
Len:= Last - I;
K:= K - (I+1);
];
];
];
int V, K;
[V:= [9, 8, 7, 6, 5, 0, 1, 2, 3, 4];
for K:= 0 to 10-1 do
[IntOut(0, QuickSelect(V, 10, K));
ChOut(0, ^ );
];
]