ocaml: phase 5.1 kth_two.ml baseline (8th smallest of two sorted = 8)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 26s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 26s
Two-pointer merge advancing the smaller-head pointer k times,
without materializing the merged array:
while !count < k do
let pick_a =
if !i = m then false (* a exhausted, take from b *)
else if !j = n then true (* b exhausted, take from a *)
else a.(!i) <= b.(!j)
in
if pick_a then ... else ...;
count := !count + 1
done
For a = [1;3;5;7;9;11;13], b = [2;4;6;8;10;12]:
merged order: 1,2,3,4,5,6,7,8,9,10,11,12,13
8th element = 8.
Tests nested if/else if/else flowing into a bool, dual-ref
two-pointer loop, separate count counter for k-th constraint.
184 baseline programs total.
This commit is contained in:
@@ -102,6 +102,7 @@
|
||||
"json_pretty.ml": 24,
|
||||
"kadane.ml": 6,
|
||||
"kmp.ml": 5,
|
||||
"kth_two.ml": 8,
|
||||
"knapsack.ml": 36,
|
||||
"lambda_calc.ml": 7,
|
||||
"lcs.ml": 4,
|
||||
|
||||
Reference in New Issue
Block a user