Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,21 @@
|
|||
let shellsort a =
|
||||
let len = Array.length a in
|
||||
let incSequence = [| 412771; 165103; 66041; 26417; 10567;
|
||||
4231; 1693; 673; 269; 107; 43; 17; 7; 3; 1 |] in
|
||||
|
||||
Array.iter (fun increment ->
|
||||
if (increment * 2) <= len then
|
||||
for i = increment to pred len do
|
||||
let temp = a.(i) in
|
||||
let rec loop j =
|
||||
if j < 0 || a.(j) <= temp then (j)
|
||||
else begin
|
||||
a.(j + increment) <- a.(j);
|
||||
loop (j - increment)
|
||||
end
|
||||
in
|
||||
let j = loop (i - increment) in
|
||||
a.(j + increment) <- temp;
|
||||
done;
|
||||
) incSequence;
|
||||
;;
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
let () =
|
||||
let arraysize = 1000 in (* or whatever *)
|
||||
Random.self_init();
|
||||
let intArray =
|
||||
Array.init arraysize (fun _ -> Random.int 4000)
|
||||
in
|
||||
shellsort intArray;
|
||||
Array.iter (Printf.printf " %d") intArray;
|
||||
print_newline();
|
||||
;;
|
||||
Loading…
Add table
Add a link
Reference in a new issue