Files
rose-ash/lib/ocaml
giles d4eb57fa07
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 26s
ocaml: phase 5.1 catalan.ml baseline (Catalan number C(5) = 42)
DP recurrence:

  C(0) = 1
  C(n) = sum_{j=0}^{n-1} C(j) * C(n-1-j)

  let catalan n =
    let dp = Array.make (n + 1) 0 in
    dp.(0) <- 1;
    for i = 1 to n do
      for j = 0 to i - 1 do
        dp.(i) <- dp.(i) + dp.(j) * dp.(i - 1 - j)
      done
    done;
    dp.(n)

C(5) = 42 — also the count of distinct binary trees with 5 internal
nodes, balanced paren strings of length 10, monotonic lattice paths,
etc.

106 baseline programs total.
2026-05-09 21:06:10 +00:00
..