feat: Add binary exponentiation algorithm#14
Open
dcq-31 wants to merge 1 commit into
Open
Conversation
Adds Binary Exponentiation to the Divide and Conquer category. Computes aⁿ in O(log n) by halving the exponent at each recursive step, visualized through the call stack concept type. - 11-step trace of binPow(2, 10) = 1024 covering both even and odd exponent cases (10 → 5 → 2 → 1 → 0) - Bilingual step descriptions and About-tab content (en/es) - README.md and README_ES.md updated; also adds previously omitted Bucket Sort entry under Sorting
|
@dcq-31 is attempting to deploy a commit to the midudev pro Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add Binary Exponentiation algorithm to Divide and Conquer category
Summary
Adds Binary Exponentiation — the classic O(log n) fast-power algorithm — to the existing Divide and Conquer / Divide y vencerás category, which previously contained only Tower of Hanoi. Computes aⁿ by halving the exponent at each recursive step, visualized through the call stack concept so the logarithmic recursion depth is immediately visible.
Changes
src/lib/algorithms/divide-and-conquer.tsaddsbinaryExponentiation(concept / callStack visualization, bilingual steps via thed()helper).src/lib/algorithms/index.tsunder the existingDivide and Conquercategory.binary-exponentiationinsrc/i18n/translations.ts.README.mdandREADME_ES.md. Also adds the previously omitted Bucket Sort entry to the Sorting / Ordenamiento sections — Bucket Sort was already implemented insrc/lib/algorithms/sorting.tsand registered inindex.tsbut had never been listed in the READMEs.Visualization
Trace of
binPow(2, 10) = 1024shown as an animated call stack across 11 steps:waiting.binPow(2, 0): returns 1, frame highlights green.half=4, 5 is odd → 4×4×2 = 32.Both the even-exponent case (
half × half) and the odd-exponent case (half × half × base) appear in this single trace, since 10 has bits in both positions (10 = 1010₂).