Skip to content

docs: fix wrong examples and time/space claims#237

Merged
cameroncuster merged 3 commits into
devfrom
doc-examples-audit
Jul 8, 2026
Merged

docs: fix wrong examples and time/space claims#237
cameroncuster merged 3 commits into
devfrom
doc-examples-audit

Conversation

@cameroncuster

Copy link
Copy Markdown
Member

Full audit of every @code example, @time/@space claim, and semantic statement across all 136 library headers. Three parallel sweeps (data structures / math+graphs+convolution / trees+strings+monotonic_stack+dsu), each flagged item then hand-verified against the code before editing. Comment-only change; 0 code lines touched.

Fixes (6 files):

File Was Now Why
data_structures_[l,r)/bit.hpp walk2 returns min r s.t. sum of [0,r] >= sum sum of [0,r+1) closed-interval doc copied into the half-open directory; re-derived from code: walk2 returns r with prefix(r) < sum <= prefix(r+1). The [l,r] twin's doc is already correct for its convention
graphs/min_vertex_cover.hpp @time O(n + q * log n), @space O(n * \alpha(n)) @time O(n + m), @space O(n) cover() is one BFS pass over the matching graph; there are no queries and no DSU — the old claims were pasted from elsewhere
strings/.../compare_substrings.hpp if cmp1<0 ... (x3) if cmp<0 ... example variable is cmp, not cmp1
math/partitions.hpp "partitions of i numbers" "partitions of i" p[i] counts integer partitions of i (A000041), not partitions of an i-element set
math/num_distinct_subsequences.hpp "subsquence" "subsequence" typo
convolution/min_plus_convolution...hpp res[k] = min of (a[i]+b[j]) min of (convex[j]+arbitrary[i]) doc referenced params a,b that don't exist; index order matches the code (convex[j], arbitrary[i], i+j==k)

Flagged by the sweeps but verified correct, so NOT changed:

  • dijkstra.hpp O(n + m log m) — correct for lazy-deletion Dijkstra (heap holds up to m entries; O(m log m) = O(m log n))
  • mod_division.hpp O(log(y)) — Euclid on (y, mod) is O(log min(y, mod)) <= O(log y)
  • linear_lca.hpp / linear_kth_par.hpp O(n + q) — queries are O(1) given O(1) hardware bit ops (bit_floor/bit_width), which is the standard model
  • derangements.hpp indexing — dp[1]=0 falls out of zero-init; matches A000166
  • lcs_queries.hpp O(nm log m + q log m + q log q) — the q log q term is real (per-row query sorts)
  • monotonic_stack/cart tree/manacher/suffix array semantics — all exactly match code and tests

Validation:

  • diff is 100% //! comment lines (checked mechanically)
  • clang-format-22 --dry-run --Werror --style=file:.config/dev.clang-format passes on all 6 files
  • all changed doc lines fit 59 columns
  • affected tests compile: bit, bit_walk, hopcroft_karp (min_vertex_cover), min_plus_convolution, num_subsequences, partitions, lcp_query_zfunc (cmp_substrs)

Based on doc-contracts (#236) to avoid conflicts; if #236 merges first this rebases cleanly (no overlapping hunks).

Comment thread library/math/matrix_related/matrix_mult.hpp Outdated
@cameroncuster cameroncuster merged commit 3eeccbd into dev Jul 8, 2026
7 of 8 checks passed
@cameroncuster cameroncuster deleted the doc-examples-audit branch July 8, 2026 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant