CSE331 Lecture 30

CSE331 Lecture 30 - return a b a 1 = a n-1 ,,a [n/2] and a...

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

View Full Document Right Arrow Icon
Lecture 30 CSE 331 Nov 9, 2011
Background image of page 1

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

View Full DocumentRight Arrow Icon
Online Office Hr @ 10:00- 10:30pm
Background image of page 2
Possible review session
Background image of page 3

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

View Full DocumentRight Arrow Icon
Need a scribe volunteer
Background image of page 4
Integer Multiplication Input: a = ( a n-1 ,.., a 0 ) and b = ( b n-1 ,…, b 0 ) Output: c = a x b a = 11 01 b = 10 01 c = 1110101
Background image of page 5

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

View Full DocumentRight Arrow Icon
Some notation Dec( a ) = Dec( a 1 ) 2 [n/2] + Dec( a 0 ) a 1 = 11 and a 0 = 01 Dec( a ) = a n-1 2 n-1 + a n-2 2 n-2 +…+ a 1 2 + a 0 a = 11 01 Dec( a ) = 13 a 1 = ( a n-1 ,.., a [n/2] ) a 0 =( a [n/2]-1 ,…, a 0 ) Dec( a ) = a n-1 2 n-1 +…+ a [n/2] 2 [n/2] + a [n/2]-1 2 [n/2]-1 +…+ a 0 = 2 [n/2] ( a n-1 2 n-[n/2]-1 +…+ a [n/2] ) + a [n/2]-1 2 [n/2]-1 +…+ a 0
Background image of page 6
Today’s agenda Design Divide and Conquer Multiplication Algorithm
Background image of page 7

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

View Full DocumentRight Arrow Icon
The algorithm so far… Mult over n bits Mult over n bits Multiplication over n/2 bit inputs Multiplication over n/2 bit inputs Shift by O(n) bits Shift by O(n) bits Adding O(n) bit numbers Adding O(n) bit numbers T(n) 4 T(n/2) + cn T(1) c T(n) is O(n 2 ) T(n) is O(n 2 )
Background image of page 8
The key identity
Background image of page 9

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

View Full DocumentRight Arrow Icon
The final algorithm Input: a = ( a n-1 ,.., a 0 ) and b = ( b n-1 ,…, b 0 ) If n = 1
Background image of page 10
Background image of page 11

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

View Full DocumentRight Arrow Icon
Background image of page 12
Background image of page 13

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

View Full DocumentRight Arrow Icon
Background image of page 14
Background image of page 15

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

View Full DocumentRight Arrow Icon
Background image of page 16
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: return a b a 1 = a n-1 ,,a [n/2] and a = a [n/2]-1 ,, a Compute b 1 and b from b Mult ( a , b ) Let p = Mult ( x , y ), D = Mult ( a 1 , b 1 ), E = Mult ( a , b ) T(1) c T(n) 3T(n/2) + cn O(n log 3 ) = O(n 1.59 ) run time O(n log 3 ) = O(n 1.59 ) run time (Old) Reading Assignment Sec 5.2 of [KT] Rankings How close are two rankings? Rest of todays agenda Formal problem: Counting inversions Divide and Conquer algorithm Divide and Conquer Divide up the problem into at least two sub-problems Recursively solve the sub-problems Patch up the solutions to the sub-problems for the final solution Solve all sub-problems: Mergesort Solve some sub-problems: Multiplication Solve stronger sub-problems: Inversions...
View Full Document

This note was uploaded on 12/11/2011 for the course CSE 331 taught by Professor Rudra during the Fall '11 term at SUNY Buffalo.

Page1 / 16

CSE331 Lecture 30 - return a b a 1 = a n-1 ,,a [n/2] and a...

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

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