Home /
Expert Answers /
Computer Science /
consider-the-following-piece-of-pseudocode-function-newmultiply-a-b-n-if-n-0-return-0-e-pa596
(Solved):
Consider the following piece of pseudocode: function NewMultiply (A, B, N) if (N == 0): return 0 e ...
Consider the following piece of pseudocode: function NewMultiply (A, B, N) if (N == 0): return 0 else if (N == 1): return A[0]*B[0] h=floor (N/2) x=N mod 2 A1=new array(h+x) of zeroes B1=new array(h+x) of zeroes for x <=i< h A1[i]=A[i] B1[i]=B[i] A2=new array(h+x) of zeroes B2=new array(h+x) of zeroes for h < i < N A2[i]=A[i] B2[i]=B[i] m1=NewMultiply (A1, B1, h+x) m2=NewMultiply (A1, B2, h+x) m3=NewMultiply (A2, B1, h+x) m4=NewMultiply (A2,B2, h+x) return m1* (2^(2h+2x))+ (m2+m3) * (2^(h+x)) + m4 end function This piece of pseudocode computes the (decimal) integer obtained from multiplying the two arrays of length N storing bits. The operation floor (x) returns the largest integer smaller than or equal to x. (e) Another colleague claims that the algorithm in NewMultiply has the best worst- case time complexity for any algorithm that takes two arrays of bits and computes the (decimal) integer corresponding to the multiplication of the two integers in the arrays. Do you agree or disagree? Explain your answer. You can use any form of research for your answer as long as you appropriately reference your resources.