-
-
Notifications
You must be signed in to change notification settings - Fork 30.7k
Add karatsubaMultiplication #159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add karatsubaMultiplication #159
Conversation
Codecov Report
@@ Coverage Diff @@
## master #159 +/- ##
======================================
Coverage 100% 100%
======================================
Files 123 135 +12
Lines 2342 2502 +160
Branches 396 418 +22
======================================
+ Hits 2342 2502 +160
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tapasweni-pathak this algorithm would be a great addition! There is a bug in the current code though, the returned result of multiplying two numbers is not correct.
Also, I think it would be good to give this algorithm its own folder - algorithms/math/karatsuba
. Within the folder, there could be a couple different variations. I wrote an alternate implementation that does not use bit-wise operators.
I would be happy to pair program with you to figure out the bug and to reorganize the algorithm into its own section.
Alternatively, you could add me as a collaborator to your fork, or I could submit a different PR and add you as a collaborator to my fork. Let me know which one you'd prefer. Thanks!
it('should multiply two numbers using karatsuba multiplication', () => { | ||
const A = 1234; | ||
const B = 5678; | ||
expect(karatsubaMultiplication(A, B)).toBe(12225730); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a bug in the algorithm. 1234 * 5678 = 7006652
Hey: Thanks for the comments and sorry for missing earlier, I am closing the pr now. |
This adds implementation of Karatsuba multiplication.