Question: Question 1 . ( 2 0 marks ) In class we discussed Karatsuba's divide - and - conquer algorithm FASTMult ( x , y )
Question marks In class we discussed Karatsuba's divideandconquer algorithm FASTMult
which takes as inputs the binary representations and of two nonnegative integers, and computes the
binary representation of their product.
a Following is an algorithm with line left incomplete which takes as input a positive integer that is
a power of two, and computes the binary representation of the number ten to th power ie the number
that is written in decimal as a followed by
POWEROFTEnTOBinaryn
if n then return the binary string that represents the number ten
else
x:
return FAStMultxx
Complete the missing expression in line explain why this algorithm works, and analyze its running time.
b Following is an algorithm with line left incomplete which takes as input the decimal representation
of a nonnegative integer whose number of digits is a power of and computes the binary representation
of that number. Assume that length is a string of digits dots, where is the most
significant and the least significant digit of the input, and that you have defined an array
binary which, for any digit gives the binary representation of ; ie binary binary
binary up to binary
Complete the missing expression in line explain why this algorithm works, and analyze its running time.
In constructing the missing expression, you may assume that, in addition to the algorithms PowerOf
TenToBinary and FastMult, you are given a function which takes as input the binary
representations a and of two nonnegative integers and returns the binary representation of their sum in
length length time.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
