Problem 4: Design divide and conquer algorithm for big number multiplication that splits number into 3 parts. l.e. given inputs X and Y: X = A^{2n/3} + B^{n/3} + C and Y = D^{2n/3} + E^{n/3} + F where n is the length of X (number of digits). Example: X = 123456 X = 12 \times 10^4 + 34 \times 10^2 + 56 where 4 = 2 \times 6/3 power 2n/3 2 = 6/3 power n/3 Provide 1) mathematical formula 2) pseudo-code 3) recurrence describing run-time of the algorithm. Solve it by using Master theorem 4) (extra credit) can you optimize it similar to what we did in class (reminder -- in class we optimized from 4 to 3 recursive calls). What is the recurrence for the new algorithm. Is it faster then optimized algorithm from class?
Added by James G.
Close
Step 1
The algorithm splits the numbers into three parts and recursively multiplies them. The time complexity of splitting the numbers and combining the results is O(n). Show more…
Show all steps
Your feedback will help us improve your experience
Deepak Kumar and 77 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
Find recurrence relation for Gn, the number of ways to give away Sl or $2 or S3 for n days with the constraint that there is an even number of days when SI is given away. Find recurrence relation to count the number of n-digit binary sequences with at least one instance of consecutive Os. Find recurrence relation for the number of n-digit quaternary (0, 1, 2, 3) sequences with at least one ad the first occurring before the first 0 (possibly no Os). Find a recurrence relation for the number of n-digit ternary (0, 1, 2) sequences in which no appears anywhere to the right of any 2.
Sri K.
a) Set up a divide-and-conquer recurrence relation for the number of modular multiplications required to compute $a^{n}$ mod $m,$ where $a, m,$ and $n$ are positive integers, using the recursive algorithms from Example 4 in Section $5.4 .$ b) Use the recurrence relation you found in part (a) to construct a big- O estimate for the number of modular multiplications used to compute $a^{n}$ mod $m$ using the recursive algorithm.
Advanced Counting Techniques
Divide-and-Conquer Algorithms and Recurrence Relations
(Calculus required) Let $\left\{C_{n}\right\}$ be the sequence of Catalan numbers, that is, the solution to the recurrence relation $C_{n}=\sum_{k=0}^{n-1} C_{k} C_{n-k-1}$ with $C_{0}=C_{1}=1$ (see Example 5 in Section 8.1$)$ a) Show that if $G(x)$ is the generating function for the sequence of Catalan numbers, then $x G(x)^{2}-G(x)+$ $1=0 .$ Conclude (using the initial conditions) that $G(x)=(1-\sqrt{1-4 x}) /(2 x)$ b) Use Exercise 42 to conclude that $$ G(x)=\sum_{n=0}^{\infty} \frac{1}{n+1}\left(\begin{array}{c}{2 n} \\ {n}\end{array}\right) x^{n} $$ so that $$ C_{n}=\frac{1}{n+1}\left(\begin{array}{c}{2 n} \\ {n}\end{array}\right) $$ c) Show that $C_{n} \geq 2^{n-1}$ for all positive integers $n$
Generating Functions
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
18,000,000+
Students on Numerade
Trusted by students at 8,000+ universities
Watch the video solution with this free unlock.
EMAIL
PASSWORD