Skip to content

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

Closed
wants to merge 3 commits into from
Closed

Add karatsubaMultiplication #159

wants to merge 3 commits into from

Conversation

tapaswenipathak
Copy link
Contributor

This adds implementation of Karatsuba multiplication.

@tapaswenipathak tapaswenipathak mentioned this pull request Aug 11, 2018
11 tasks
@codecov-io
Copy link

Codecov Report

Merging #159 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff           @@
##           master   #159    +/-   ##
======================================
  Coverage     100%   100%            
======================================
  Files         123    135    +12     
  Lines        2342   2502   +160     
  Branches      396    418    +22     
======================================
+ Hits         2342   2502   +160
Impacted Files Coverage Δ
...rc/algorithms/math/bits/karatsubaMultiplication.js 100% <100%> (ø)
...rc/algorithms/math/complex-number/ComplexNumber.js 100% <0%> (ø) ⬆️
src/data-structures/heap/MinHeap.js 100% <0%> (ø) ⬆️
src/data-structures/trie/Trie.js 100% <0%> (ø) ⬆️
src/data-structures/stack/Stack.js 100% <0%> (ø) ⬆️
src/data-structures/queue/Queue.js 100% <0%> (ø) ⬆️
src/algorithms/sets/power-set/powerSet.js
src/data-structures/heap/Heap.js 100% <0%> (ø)
...s/math/fourier-transform/__test__/FourierTester.js 100% <0%> (ø)
src/algorithms/math/radian/degreeToRadian.js 100% <0%> (ø)
... and 10 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3c37ba4...859bcab. Read the comment docs.

Copy link
Contributor

@appleJax appleJax left a 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);
Copy link
Contributor

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

@tapaswenipathak
Copy link
Contributor Author

Hey: Thanks for the comments and sorry for missing earlier, I am closing the pr now.

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.

3 participants