Skip to content

Fix #39 misc time items: heaps, hash-sets, no re-sorts - #43

Closed
m-hu wants to merge 1 commit into
masterfrom
fix/39-misc-complexity
Closed

m-hu wants to merge 1 commit into
masterfrom
fix/39-misc-complexity

Conversation

@m-hu

@m-hu m-hu commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator

Part of #39 — the eight remaining time-complexity items across dp,
data_structure, distributed, systems, search, combinatorics.

Changes

  • dp/huffman/huffman: binary heap, no per-merge re-sort
    (n=30000: 17.00s → 0.74s).
  • dp/offline_caching/offline_caching: reduce-over-set eviction, no
    per-eviction sort (k=1000/m=40000: 7.95s → 2.10s).
  • data_structure/offline_minimum/solution: binary search for first
    extract after insert (m=30000: 7.45s → 2.10s).
  • distributed/consensus/approx_agreement/approx_agreement: sort
    once/round + hoisted mean (2.70s → 0.69s).
  • systems/cpu_scheduling/solution: round-robin head-index queue with
    amortized compaction, no vec(rest) copies (7.42s → 0.55s).
  • systems/distance_vector_routing/solution: on-demand poison-reverse
    lookup, no N³ table (N=200: 2.59s → 0.77s).
  • search/pl_resolution/pl_resolution: hash-set clause membership
    (19.72s → 2.65s).
  • combinatorics/prufer/prufer: sorted-set min-leaf heap for
    encode+decode (decode n=15000: 1.60s → 0.60s).

Validation

  • Hand-built small cases (3–6 per file incl. edge cases) + adversarial
    scale cases, each before (HEAD) vs after via JVM clojure.main:
    all outputs byte-identical, all scale runs faster. Shared GPG cases
    unavailable locally — CI covers them.

AI-Tool: Muse Code (Meta Muse Spark)

huffman: binary heap keyed [weight,min-leaf,id], no per-merge re-sort.
offline_caching: eviction scans cache once, no per-eviction sort.
offline_minimum: binary search for first extract after insert.
approx_agreement: sort once per round, hoist trimmed mean.
cpu_scheduling: RR ready queue via head index + amortized compaction.
distance_vector: on-demand poison-reverse lookup, no N^3 table.
pl_resolution: hash-set clause membership instead of linear scan.
prufer: sorted-set min-leaf heap for encode and decode.

AI-Tool: Muse Code (Meta Muse Spark)
@m-hu

m-hu commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator Author

Superseded by #45 — all four area branches merged into one batch PR.

@m-hu m-hu closed this Nov 3, 2026
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