Intro to Computer Algorithms Lecture 9 - PowerPoint PPT Presentation

1 / 16
About This Presentation
Title:

Intro to Computer Algorithms Lecture 9

Description:

Coop Interview Days: Oct 14th and 15th. Signup begins on 22nd of September ... Brassard & Bratley's simulations. Matrix Multiplication. Grade School Algorithm ... – PowerPoint PPT presentation

Number of Views:158
Avg rating:3.0/5.0
Slides: 17
Provided by: pgb8
Category:

less

Transcript and Presenter's Notes

Title: Intro to Computer Algorithms Lecture 9


1
Intro to Computer Algorithms Lecture 9
  • Phillip G. Bradford
  • Computer Science
  • University of Alabama

2
Announcements
  • Advisory Boards Industrial Talk Series
  • http//www.cs.ua.edu/9IndustrialSeries.shtm
  • Coop Interview Days Oct 14th and 15th
  • Signup begins on 22nd of September
  • At least 40 firms looking for coop students!

3
ACM announces Movie Night
  • When and Where Thursday, September 25, 2003
  • 630 pm in room 119 EE
  • EVERYONE IS INVITED!!!!
  • The Movie will be Office Space
  • We will have subway platters
  • No Admission fee
  • If you have any questions, go to our newly
    updated website and post them on the forum
    http//www.studentacm.org

4
Outline
  • Integer Multiplication
  • Fast Integer Multiplication
  • Matrix Multiplication
  • Start Strassens Algorithm

5
Integer Multiplication
  • Cost of multiplying two n-digit integers
  • Basic Grade-School Algorithm
  • 23 2101 3100 a1101 a0100
  • 14 1101 4100 b1101 b0100
  • (a1 a0)(b1 b0)
  • Or (a1b1 a1b0) (a0b1 a0b0 )
  • Consider the product of
  • an10n a0100
  • bn10n b0100
  • What does this cost?
  • O(n2) digit multiplication operations

6
Integer Multiplication
  • Can we do any better?
  • 23 2101 3100
  • 14 1101 4100
  • 2314 (21)102 (3124)101 (34)100
  • Four multiplications
  • Powers of 10 can be done via shifting

7
Integer Multiplication
  • Note (31)(24) (23)(14) (21)-(34)
  • Because (a1a0)(b1b0) a1b1a1b0a0b1a0b0
  • Focus on a1b0a0b1 both times 101
  • Subtract off a1b1 a0b0
  • We must compute a1b1 a0b0 anyway!

8
Integer Multiplication
  • Can we generalize this?
  • Let a a1101 a0100
  • And b b1101 b0100
  • C ab c2102 c1101 c0100
  • Where c2 a1b1 and c0 a0b0
  • Therefore c1 (a1a0)(b1b0) (c2 c0)

9
Fast Integer Multiplication
  • Divide-and-Conquer generalization!
  • Conceptual Example
  • Let A1 a101010 a5105
  • And A0 a4104 a0100
  • So, Letting A1 ? A1/105 and B1 ? B1/105
  • Gives A A1105 A0
  • Likewise for B B1105 B0
  • Thus, AB (A1105 A0)(B1105 B0)

10
Fast Integer Multiplication
  • In general, giving
  • AB A1B110n (A1B0A0B1)10n/2 A0B0
  • For the time being, say n is a power of 2
  • Do this with 3 multiplications instead of 4
  • AB C210n C110n/2 C0
  • Where C2 A1B1 and C0 A0B0
  • And C1 (A1A0)(B1B0) (C2 C0)

11
Fast Integer Multiplication
  • Convince me this works!
  • Recurrence
  • Fundamental operation is multiplication
  • What does this cost?
  • T(n) 3T(n/2) for n gt 1
  • T(1) 1.
  • Can we use the Master Theorem?

12
Fast Integer Multiplication
  • Solve T(n) by backward substitution
  • Let n 2k
  • Then T(2k) 3iT(2k-i)
  • Thus, T(n) 3k for n 2k.
  • Since, k log2n
  • It must be that T(n) 3log2n
  • Using alogb c clogb a
  • T(n) nlog23 O(n1.585)

13
Fast Integer Multiplication
  • How can we prove
  • alogb c clogb a ?
  • Brassard Bratleys simulations

14
Matrix Multiplication
  • Grade School Algorithm
  • M and N, say n-by-n matrices
  • Output P
  • For i?1 to n do
  • For j?1 to n do
  • Pi,j ? 0
  • For k? 1 to n do
  • Pi,j ? Pi,j Mi,kNk,j

15
Matrix Multiplication
  • Cost?
  • O(n3)
  • Can we do better?

16
Strassens Algorithm
  • Cost O(n2.807)
Write a Comment
User Comments (0)
About PowerShow.com