Question
c++ 1. Read two digit strings a and b, separated by a newline character, from standard input (that is, from cin). Store each as an
c++
1. Read two digit strings a and b, separated by a newline character, from standard input (that is, from cin). Store each as an array of digits. The numbers a and b may be very large, potentially thousands of digits each. Either or both of the numbers may be zero.
2. Multiply a and b using the (n 2 ) time brute force algorithm alluded to in class. The text book mentions this algorithm on page 187 as the pencil and paper algorithm. Its also the method that is usually taught to small children.
3. Output the text Brute Force: , followed by the answer from Step (2).
4. Multiply a and b again using the divide-and-conquer Karatsuba multiplication algorithm.
5. Output the text Karatsuba: , followed by the answer from Step (4).
Heres an example run, with the users input shown in italics: 1234 5678 Brute force: 7006652 Karatsuba: 7006652 Thats it. Just multiply the two numbers using both algorithms.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started