DivideNConquer-II - Divide and Conquer(Part II...

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

View Full Document Right Arrow Icon
Divide and Conquer (Part II) ultiplication of two numbers Multiplication of two numbers Let U = ( u 2 n -1 u 2 n -2 u 1 u 0 ) 2 and V = ( v 2 n -1 v 2 n -2 v 1 v 0 ) 2 , and our goal is to find U times V . Ordinary multiplication requires execution time α ( n 2 ). Alternatively, let U = 2 n U 1 + U 0 and V = 2 n V 1 + V 0 where U 1 = ( u 2 n -1 u 2 n -2 u n ) 2 and U 0 = ( u n -1 u n -2 u 0 ) 2 Likewise, V 1 = ( v 2 n -1 v 2 n -2 v n ) 2 and V 0 = ( v n -1 v n -2 v 0 ) 2 U X V = 2 2n U 1 V 1 + 2 n ( U 1 V 0 + U 0 V 1 ) + U 0 V 0 . Apparently there is no saving, this multiplication also requires execution time proportional to n 2. 1/21/2010
Background image of page 1

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

View Full Document Right Arrow Icon
Divide and Conquer (Part II) ultiplication: Divide and Conquer Multiplication: Divide and Conquer U X V = (2 2n + 2 n ) U 1 V 1 + 2 n ( U 1 –U 0 )( V 0 –V 1 ) + (2 n + 1) U 0 V 0 . which requires only three multiplications and some extra addition. If T ( n ) denotes time to multiply two binary integers of size hth n each, then T (2 n ) = 3 T( n ) + c n , and T (1) =1, where cn denotes the cost associated with additions and shifting of binary integers etc. . 1/21/2010
Background image of page 2
Divide and Conquer (Part II) ultiplication: Divide and Conquer Multiplication: Divide and Conquer Solution of this recurrence equation is (by Master Theorem) or repeated substitution, for n = 2 m , is T (2 m ) = 3 m T (1) + c (3 m -2 m ) In general, lg n ) + c(3 lg n - lg n T ( n ) 3 T (1) + c(3 2 ) 3c X 3 lg n 3 585 = 3c X n lg 3 3c X 1.585 1/21/2010
Background image of page 3

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

View Full Document Right Arrow Icon
Divide and Conquer (Part II) atrix ultiplication Matrix Multiplication Let C = AB = ( c ij ) be the product of two n x n matrices A and B , where a 11 a 12 a 1 n b b 12 b 1 n A = a 21 a 22 a 2 n and B = b 21 b 22 b 2 n a n 1 a n 2 a nn b n 1 b n 2 b nn • We calculate n 2 terms, c ij for i =1,2,…, n , , j =1,2,…, n . ach quires alar multiplications Each c ij requires n scalar multiplications. • Therefore, total complexity of this matrix multiplication is of the order n 3 . 1/21/2010
Background image of page 4
Divide and Conquer (Part II) Suppose n = 2 k for some integer value of k . Let r sa be g C = = A X B = X t uc df h Where r,s,t,u are all n/2 X n/2 matrices • In this way of obtaining C , by first partitioning A and B in submatrices, we calculate 4 matrices r , s , t , and u .
Background image of page 5

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

View Full Document Right Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 25

DivideNConquer-II - Divide and Conquer(Part II...

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

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