ocaml: phase 5.1 lps_dp.ml baseline (LPS "BBABCBCAB" = 7)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 21s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 21s
Standard O(n^2) length-major DP for longest palindromic
subsequence:
dp[i][j] = dp[i+1][j-1] + 2 if s[i] = s[j]
= max(dp[i+1][j], dp[i][j-1]) otherwise
lps "BBABCBCAB" = 7 (witness "BABCBAB" etc.)
Complementary to manacher.ml (longest palindromic *substring*,
also length 7 on that input by coincidence) — this is the
subsequence variant which doesn't require contiguity.
Tests length-major fill order, inline if for the length-2 base
case, double-nested for with derived j = i + len - 1.
177 baseline programs total.
This commit is contained in:
@@ -407,6 +407,15 @@ _Newest first._
|
||||
binary search tree (`type 'a tree = Leaf | Node of 'a * 'a tree *
|
||||
'a tree`) with insert + in-order traversal. Tests parametric ADT,
|
||||
recursive match, List.append, List.fold_left.
|
||||
- 2026-05-11 Phase 5.1 — lps_dp.ml baseline (longest palindromic
|
||||
subsequence in "BBABCBCAB" = 7). Classic 2D O(n²) DP over
|
||||
substring lengths: dp[i][j] = dp[i+1][j-1] + 2 when s[i]=s[j],
|
||||
else max(dp[i+1][j], dp[i][j-1]). Witness LPS is "BABCBAB" (or
|
||||
"BACBCAB" etc.) of length 7. Complementary to manacher.ml
|
||||
(substring, length 7) — this is the subsequence variant.
|
||||
Tests length-major fill order, mixed strict/inline if for
|
||||
`len = 2` base case, double-nested for with derived j. 177
|
||||
baseline programs total.
|
||||
- 2026-05-11 Phase 5.1 — bs_bounds.ml baseline (lower_bound /
|
||||
upper_bound binary search; counts of {3,2,5,9,4} in
|
||||
[1;2;2;3;3;3;5;7;9] encoded as 3211). Standard half-open
|
||||
|
||||
Reference in New Issue
Block a user