ocaml: phase 5.1 kmp.ml baseline (5 occurrences of "abab" in haystack)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 21s

Knuth-Morris-Pratt linear-time string search:
  - kmp_table builds failure function in O(|pattern|)
  - kmp_search scans text once in O(|text|), counting matches
  - After a hit, k := t.(n-1) so overlapping matches still count

  kmp_search "abababcabababcababcc" "abab" = 5

Hits at positions 0, 2, 7, 9, 14 (overlapping at 0/2 and 7/9).

Tests: nested while-inside-for, char inequality (.<>), pat.[i]
string indexing, Array.make 0, combined string + array indexing.

140 baseline programs total.
This commit is contained in:
2026-05-10 04:08:53 +00:00
parent bcaa41d1ae
commit 713d506bb8
3 changed files with 45 additions and 0 deletions

View File

@@ -79,6 +79,7 @@
"josephus.ml": 11,
"json_pretty.ml": 24,
"kadane.ml": 6,
"kmp.ml": 5,
"lambda_calc.ml": 7,
"majority_vote.ml": 4,
"levenshtein.ml": 11,