lecture_02 - Divide and Conquer Week 1 Reading Examples...

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

View Full Document Right Arrow Icon
1 Divide and Conquer Examples • Mergesort O(n log n) time • Long integer multiplication O(n log n) time • Finding the closest pair of points O(n log n) time • Matrix mulitplication O(n 2.81 ) time • Median O(n) time Week 1 Reading • Dasgupta 2.1-2.5 • Cormen 28.2, 33.4
Background image of page 1

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

View Full DocumentRight Arrow Icon
Matrix multipliation Matrix multiplication: Let A and B be two n x n matrices of integers. Compute C = AB. Note that C[i, j] = 1 k n A[i,k] B[k,j]. C can be computed using O(n 3 ) integer operations (additions /multiplications). For i = 1 to n For j = 1 to n C[i,j] = A[i,1] x B[1,j] For k to 2 to n C[i,j] = C[i,j] + A[i, k ] x B[ k ,j]
Background image of page 2
Matrix multipliation Matrix multiplication: Let A and B be two n x n matrices of integers. Compute C = AB. Note that C[i, j] = 1 k n A[i,k] B[k,j]. Let us try divide and conquer. Assume n is a power of 2. A 11 A 21 A 12 A 22 B 11 B 21 B 12 B 22 C 11 C 21 C 12 C 22 A B = C
Background image of page 3

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

View Full DocumentRight Arrow Icon
C 11 = A 11 B 11 + A 12 B 21 C 12 = A 11 B 12 + A 12 B 22 C 21 = A 21 B
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 14

lecture_02 - Divide and Conquer Week 1 Reading Examples...

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

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