lecture 33 cse 331 nov 17, 2010. online office hours tonight @9 alex will host the office hours
Post on 22-Dec-2015
214 views
TRANSCRIPT
![Page 1: Lecture 33 CSE 331 Nov 17, 2010. Online office hours tonight @9 Alex will host the office hours](https://reader036.vdocument.in/reader036/viewer/2022062516/56649d795503460f94a5c07f/html5/thumbnails/1.jpg)
Lecture 33
CSE 331Nov 17, 2010
![Page 2: Lecture 33 CSE 331 Nov 17, 2010. Online office hours tonight @9 Alex will host the office hours](https://reader036.vdocument.in/reader036/viewer/2022062516/56649d795503460f94a5c07f/html5/thumbnails/2.jpg)
Online office hours tonight @9
Alex will host the office hours
![Page 3: Lecture 33 CSE 331 Nov 17, 2010. Online office hours tonight @9 Alex will host the office hours](https://reader036.vdocument.in/reader036/viewer/2022062516/56649d795503460f94a5c07f/html5/thumbnails/3.jpg)
Next Monday’s lecture
I’ll be out of town
Jeff will teach the lecture
![Page 4: Lecture 33 CSE 331 Nov 17, 2010. Online office hours tonight @9 Alex will host the office hours](https://reader036.vdocument.in/reader036/viewer/2022062516/56649d795503460f94a5c07f/html5/thumbnails/4.jpg)
Feedback Forms
Link for the survey on the blog
![Page 5: Lecture 33 CSE 331 Nov 17, 2010. Online office hours tonight @9 Alex will host the office hours](https://reader036.vdocument.in/reader036/viewer/2022062516/56649d795503460f94a5c07f/html5/thumbnails/5.jpg)
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
![Page 6: Lecture 33 CSE 331 Nov 17, 2010. Online office hours tonight @9 Alex will host the office hours](https://reader036.vdocument.in/reader036/viewer/2022062516/56649d795503460f94a5c07f/html5/thumbnails/6.jpg)
Integer Multiplication
Input: a = (an-1,..,a0) and b = (bn-1,…,b0)
Output: c = a x b
a = 1101 b = 1001
c =1110101
a = a12[n/2] + a0 a1 = 11 and a0 = 01
b = b12[n/2] + b0 b1 = 10 and b0 = 01
![Page 7: Lecture 33 CSE 331 Nov 17, 2010. Online office hours tonight @9 Alex will host the office hours](https://reader036.vdocument.in/reader036/viewer/2022062516/56649d795503460f94a5c07f/html5/thumbnails/7.jpg)
First attempt
Mult over n bits
Mult over n bits
Multiplication over n/2 bit inputsMultiplication over n/2 bit inputs
Shift by O(n) bitsShift by O(n) bits
Adding O(n) bit numbersAdding O(n) bit numbers
T(n) ≤ 4T(n/2) + cn T(1) ≤ c
T(n) is O(n2)T(n) is O(n2)
![Page 8: Lecture 33 CSE 331 Nov 17, 2010. Online office hours tonight @9 Alex will host the office hours](https://reader036.vdocument.in/reader036/viewer/2022062516/56649d795503460f94a5c07f/html5/thumbnails/8.jpg)
The key identity
![Page 9: Lecture 33 CSE 331 Nov 17, 2010. Online office hours tonight @9 Alex will host the office hours](https://reader036.vdocument.in/reader036/viewer/2022062516/56649d795503460f94a5c07f/html5/thumbnails/9.jpg)
The final algorithmInput: a = (an-1,..,a0) and b = (bn-1,…,b0)
If n = 1 return a0b0
a1 = an-1,…,a[n/2] and a0 = a[n/2]-1,…, a0
Compute b1 and b0 from b
Mult (a, b)
Let p = Mult (x, y), D = Mult (a1, b1), E = Mult (a0, b0)
T(1) ≤ c
T(n) ≤ 3T(n/2) + cn
O(nlog 3) = O(n1.59) run time
O(nlog 3) = O(n1.59) run time
![Page 10: Lecture 33 CSE 331 Nov 17, 2010. Online office hours tonight @9 Alex will host the office hours](https://reader036.vdocument.in/reader036/viewer/2022062516/56649d795503460f94a5c07f/html5/thumbnails/10.jpg)
![Page 11: Lecture 33 CSE 331 Nov 17, 2010. Online office hours tonight @9 Alex will host the office hours](https://reader036.vdocument.in/reader036/viewer/2022062516/56649d795503460f94a5c07f/html5/thumbnails/11.jpg)
(Old) Reading AssignmentSec 5.2 of [KT]
![Page 12: Lecture 33 CSE 331 Nov 17, 2010. Online office hours tonight @9 Alex will host the office hours](https://reader036.vdocument.in/reader036/viewer/2022062516/56649d795503460f94a5c07f/html5/thumbnails/12.jpg)
Rankings
![Page 13: Lecture 33 CSE 331 Nov 17, 2010. Online office hours tonight @9 Alex will host the office hours](https://reader036.vdocument.in/reader036/viewer/2022062516/56649d795503460f94a5c07f/html5/thumbnails/13.jpg)
How close are two rankings?
![Page 14: Lecture 33 CSE 331 Nov 17, 2010. Online office hours tonight @9 Alex will host the office hours](https://reader036.vdocument.in/reader036/viewer/2022062516/56649d795503460f94a5c07f/html5/thumbnails/14.jpg)
Today’s agenda
Formal problem: Counting inversions
Divide and Conquer algorithm