Skip to content

Rewrite UBS to use precomputed deltas and add deterministic demos#22

Merged
Nullkernel merged 1 commit intomainfrom
codex/refactor-binunisearch-with-precomputed-deltas
Apr 7, 2026
Merged

Rewrite UBS to use precomputed deltas and add deterministic demos#22
Nullkernel merged 1 commit intomainfrom
codex/refactor-binunisearch-with-precomputed-deltas

Conversation

@Nullkernel
Copy link
Copy Markdown
Owner

Motivation

  • Improve the Uniform Binary Search (UBS) probe logic to maintain valid probe intervals deterministically using precomputed deltas and a clear center-start flow.
  • Provide a deterministic demonstration that shows both a found and a not-found search to make behavior explicit for users.

Description

  • Rewrote binunisearch in Searching-algorithms/Uniform_binarysearch.java to build a delta table with buildDeltaTable(int n), start at a center probe, and move left/right by successive deltas while clamping the probe to [0, n-1].
  • Kept exact-match semantics so the function returns an index only when arr[probe] == key and otherwise returns -1.
  • Added buildDeltaTable to precompute the successive delta moves and runDeterministicDemo which runs two deterministic searches (one found, one not-found) and is invoked from main on key flow and some early-exit paths.
  • Updated main to call the deterministic demo in invalid/early-exit cases and after a normal interactive run to demonstrate behavior.

Testing

  • Compiled the updated file with javac Searching-algorithms/Uniform_binarysearch.java, which completed successfully.
  • No automated unit tests were added; behavior was validated via the deterministic demo runs included in main.

Codex Task

@Nullkernel Nullkernel merged commit e77e776 into main Apr 7, 2026
1 check passed
@Nullkernel Nullkernel deleted the codex/refactor-binunisearch-with-precomputed-deltas branch April 7, 2026 05:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant