HW3Fl03Alg

HW3Fl03Alg - Homework 3 Fall 2003 Algorithms Due: November...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Points: 50/60 Due: November 11, 2003 in class 1. Write down a pseudo-code for the divide-and-conquer Integer Multiplication algorithm. [10] function Mul(x,y) n = common bit length of x and y if n = = 1 then return x*y else a=first half of x; b=second half of x; c=first half of y; d=second half of y; p1 = Mul (a,c) p2 = Mul (a,d) + Mul (b,c) p3 = Mul (b,d) return 2^n*p1 + 2^(n/2)*p2 + p3 end if end function T(n) = 4T(n/2)+O(n) There are other answers. http://www-inst.eecs.berkeley.edu/~cs170/Notes/lecture2.pdf 2. Analyze the (a) time and (b) space complexities of the Dynamic programming algorithm for the Matrix-chain multiplication problem. [10+5] (c ) Prove the correctness of the above algorithm by mathematical (strong) induction. [5] [Hint: use n=1, one matrix as induction base, and assuming that the induction hypothesis to be true for all the chain sizes 1, 2, …, n-1 convince that it is also true for the chain size n.] a) ) ( ) ( 1 ) ( 1 0 1 1 1 1 1 1 n O k n O n T k n l n k k l l i k n l n k + = + = - - = - = - + = - = - = ) ( 6 ) 1 2 )( 1 ( 2 ) 1 )( ( ) ( ) ( ) ( 3 1 1 1 1 1 1 2 n O n n n n n n n O k nk n O k k n n k n k n k - = - = - = = - - + - = + + = + - = b) This algorithm creates a n by n matrix in order to store information, where n is the number of matrix: O(n 2 ) Each iteration takes wost-case O(n) space for calculating the minimum. The space is reused from iteration to iteration. Total: O(n
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/10/2012 for the course CSE 5211 taught by Professor Dmitra during the Spring '12 term at FIT.

Page1 / 4

HW3Fl03Alg - Homework 3 Fall 2003 Algorithms Due: November...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online