Files
rose-ash/lib/ocaml/baseline/expected.json
giles be13f2daba
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 25s
ocaml: phase 5.1 majority_vote.ml baseline (Boyer-Moore majority, [3;3;4;2;4;4;2;4;4] = 4)
O(n) time / O(1) space majority vote algorithm:

  let majority xs =
    let cand = ref 0 in
    let count = ref 0 in
    List.iter (fun x ->
      if !count = 0 then begin
        cand := x;
        count := 1
      end else if x = !cand then count := !count + 1
      else count := !count - 1
    ) xs;
    !cand

The candidate is updated to the current element whenever count
reaches zero. When a strict majority exists, this guarantees the
result.

  majority [3;3;4;2;4;4;2;4;4] = 4   (5 of 9, > n/2)

97 baseline programs total.
2026-05-09 19:27:14 +00:00

102 lines
2.1 KiB
JSON

{
"ackermann.ml": 125,
"adler32.ml": 300286872,
"anagram_check.ml": 2,
"anagrams.ml": 3,
"atm.ml": 120,
"bag.ml": 3,
"bf_full.ml": 6,
"bisect.ml": 141,
"bigint_add.ml": 28,
"bits.ml": 21,
"balance.ml": 3,
"base_n.ml": 17,
"bfs.ml": 6,
"btree.ml": 39,
"brainfuck.ml": 75,
"bsearch.ml": 7,
"caesar.ml": 215,
"calc.ml": 13,
"closures.ml": 315,
"coin_change.ml": 6,
"count_change.ml": 406,
"csv.ml": 10,
"exception_handle.ml": 4,
"exception_user.ml": 26,
"expr_eval.ml": 16,
"expr_simp.ml": 22,
"factorial.ml": 3628800,
"fib_doubling.ml": 102334155,
"fib_mod.ml": 391360,
"fraction.ml": 7,
"frequency.ml": 5,
"gcd_lcm.ml": 60,
"gray_code.ml": 136,
"grep_count.ml": 3,
"grid_paths.ml": 210,
"group_consec.ml": 53,
"hailstone.ml": 111,
"hamming.ml": 4,
"hanoi.ml": 1023,
"hist.ml": 75,
"int_sqrt.ml": 1027,
"fizzbuzz.ml": 57,
"flatten_tree.ml": 28,
"list_ops.ml": 30,
"luhn.ml": 2,
"mat_mul.ml": 621,
"max_path_tree.ml": 11,
"max_run.ml": 5,
"mod_inverse.ml": 27,
"json_pretty.ml": 24,
"kadane.ml": 6,
"lambda_calc.ml": 7,
"majority_vote.ml": 4,
"levenshtein.ml": 11,
"memo_fib.ml": 75025,
"mortgage.ml": 1073,
"merge_intervals.ml": 12,
"merge_sort.ml": 44,
"merge_two.ml": 441,
"module_use.ml": 3,
"newton_sqrt.ml": 1414,
"mutable_record.ml": 10,
"option_match.ml": 5,
"palindrome.ml": 4,
"paren_depth.ml": 7,
"pancake_sort.ml": 910,
"pascal.ml": 252,
"peano.ml": 30,
"pi_leibniz.ml": 314,
"prefix_sum.ml": 66,
"pretty_table.ml": 64,
"poly_stack.ml": 5,
"pow_mod.ml": 738639,
"prime_factors.ml": 17,
"queens.ml": 2,
"quicksort.ml": 44,
"roman.ml": 44,
"rpn.ml": 9,
"run_decode.ml": 21,
"run_length.ml": 11,
"safe_div.ml": 20,
"shuffle.ml": 55,
"simpson_int.ml": 10000,
"stable_unique.ml": 46,
"subseq_check.ml": 3,
"subset_sum.ml": 8,
"tic_tac_toe.ml": 1,
"word_freq.ml": 8,
"xor_cipher.ml": 601,
"zigzag.ml": 55,
"zip_unzip.ml": 1000,
"sieve.ml": 15,
"sum_squares.ml": 385,
"tree_depth.ml": 4,
"triangle.ml": 11,
"twosum.ml": 5,
"unique_set.ml": 9,
"validate.ml": 417,
"word_count.ml": 3
}