10.07.2015 Views

Divide and Conquer

Divide and Conquer

Divide and Conquer

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Divide</strong> <strong>and</strong> <strong>Conquer</strong> 10∗ If n ≠ 2 k , we can add enough rows <strong>and</strong> columns to make it satisfy our assumption– Each of A, B, <strong>and</strong> C is partitioned into submatrices of size n 2such that[ ] [ ] [ ]A11 A 12 B11 B 12 C11 C=12A 21 A 22 B 21 B 22 C 21 C 22– This yields eight multiplications of n 2 × n 2 matrices (T n ), <strong>and</strong> four additions of the same size of matrices (assume2cn 2 for some constant c, starting with 4 · ( n 2 )2 )– The recurrence is{ b n ≤ 2T n =8T n + cn2 n > 22– A solution of this recurrence yields T n = O(n 3 ) (no improvement)– Observation: Matrix multiplications are more expensive (O(n 3 )) than matrix additions (O(n 2 ))– Strassen’s method relies on devising a clever workaround to minimize the number of multiplications while increasingthe number of additions∗ 7 multiplications <strong>and</strong> 18 additions/subtractions– The intermediate computations are– The elements of C are given asP 1 = (A 11 + A 22 )(B 11 + B 22 )P 2 = (A 21 + A 22 )B 11P 3 = A 11 (B 12 − B 22 )P 4 = A 22 (B 21 − B 11 )P 5 = (A 11 + A 12 )B 22P 6 = (A 21 − A 11 )(B 11 + B 12 )P 7 = (A 12 − A 22 )(B 21 + B 22 )C 11 = P 1 + P 4 − P 5 + P 7C 12 = P 3 + P 5C 21 = P 2 + P 4C 22 = P 1 + P 3 − P 2 + P 6– The recurrence relation iswhere a <strong>and</strong> b are constants– Solving the recurrence{ b n ≤ 2T n =7T n + an2 n > 22T n = an 2 [1 + 7 ( 2 ( ) k−1 7 74 4) + + · · · + ] + 7 k T (1)4( lg n 7≤ cn4) 2 + 7 lg n , c is a constant= cn lg 4+lg 7−lg 4 + n lg 7= O(n lg 7 )≈ O(n 2.81 )Convex hull

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!