ocaml: phase 5.1 prefix_sum.ml baseline (precomputed sums + range queries, 14+25+27 = 66)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 28s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 28s
Two utility functions:
prefix_sums xs builds Array of len n+1 such that
arr.(i) = sum of xs[0..i-1]
range_sum p lo hi = p.(hi+1) - p.(lo)
For [3;1;4;1;5;9;2;6;5;3]:
range_sum 0 4 = 14 (3+1+4+1+5)
range_sum 5 9 = 25 (9+2+6+5+3)
range_sum 2 7 = 27 (4+1+5+9+2+6)
sum = 66
Tests List.iter mutating Array indexed by a ref counter, plus the
classic prefix-sum technique for O(1) range queries.
67 baseline programs total.
This commit is contained in:
@@ -47,6 +47,7 @@
|
||||
"palindrome.ml": 4,
|
||||
"pascal.ml": 252,
|
||||
"pi_leibniz.ml": 314,
|
||||
"prefix_sum.ml": 66,
|
||||
"pretty_table.ml": 64,
|
||||
"poly_stack.ml": 5,
|
||||
"prime_factors.ml": 17,
|
||||
|
||||
Reference in New Issue
Block a user