5 -1 Chapter 5 The Divide-and-Conquer Strategy. 5 -2 A simple example finding the maximum of a set S of n numbers.

Slides:



Advertisements
Similar presentations
Comments We consider in this topic a large class of related problems that deal with proximity of points in the plane. We will: 1.Define some proximity.
Advertisements

Map Overlay Algorithm. Birch forest Wolves Map 1: Vegetation Map 2: Animals.
Approximations of points and polygonal chains
Advanced Topics in Algorithms and Data Structures Lecture 7.2, page 1 Merging two upper hulls Suppose, UH ( S 2 ) has s points given in an array according.
Lecture 3: Parallel Algorithm Design
A simple example finding the maximum of a set S of n numbers.
 Distance Problems: › Post Office Problem › Nearest Neighbors and Closest Pair › Largest Empty and Smallest Enclosing Circle  Sub graphs of Delaunay.
The Divide-and-Conquer Strategy
Prune-and-Search Method
UNC Chapel Hill M. C. Lin Polygon Triangulation Chapter 3 of the Textbook Driving Applications –Guarding an Art Gallery –3D Morphing.
4 -1 Chapter 4 The Divide-and-Conquer Strategy Outlines 4-1 The 2-Dimensional Maxima Finding Problem 4-2 The Closest Pair Problem 4-3 The Convex.
© The McGraw-Hill Companies, Inc., Chapter 2 The Complexity of Algorithms and the Lower Bounds of Problems.
1 Voronoi Diagrams. 2 Voronoi Diagram Input: A set of points locations (sites) in the plane.Input: A set of points locations (sites) in the plane. Output:
Divide-and-Conquer The most-well known algorithm design strategy:
4 -1 Chapter 4 The Divide-and-Conquer Strategy A simple example finding the maximum of a set S of n numbers.
The Divide-and-Conquer Strategy
1 Divide-and-Conquer The most-well known algorithm design strategy: 1. Divide instance of problem into two or more smaller instances 2. Solve smaller instances.
Lectures on Recursive Algorithms1 COMP 523: Advanced Algorithmic Techniques Lecturer: Dariusz Kowalski.
Convex Hulls in Two Dimensions Definitions Basic algorithms Gift Wrapping (algorithm of Jarvis ) Graham scan Divide and conquer Convex Hull for line intersections.
CS4413 Divide-and-Conquer
The Divide-and-Conquer Strategy
5 -1 Chapter 5 The Divide-and-Conquer Strategy A simple example finding the maximum of a set S of n numbers.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Divide and Conquer.
Convex Hulls May Shmuel Wimer Bar Ilan Univ., Eng. Faculty Technion, EE Faculty.
By Groysman Maxim. Let S be a set of sites in the plane. Each point in the plane is influenced by each point of S. We would like to decompose the plane.
Advanced Topics in Algorithms and Data Structures Lecture 7.1, page 1 An overview of lecture 7 An optimal parallel algorithm for the 2D convex hull problem,
Convex Hull Problem Presented By Erion Lin. Outline Convex Hull Problem Voronoi Diagram Fermat Point.
What does that mean? To get the taste we will just look only at some sample problems... [Adapted from S.Suri]
Computational Geometry -- Voronoi Diagram
17. Computational Geometry Chapter 7 Voronoi Diagrams.
Lecture 8 Jianjun Hu Department of Computer Science and Engineering University of South Carolina CSCE350 Algorithms and Data Structure.
Chapter 3 The Greedy Method 3.
2. Voronoi Diagram 2.1 Definiton Given a finite set S of points in the plane , each point X of  defines a subset S X of S consisting of the points of.
3. Delaunay triangulation
1 Lecture 8: Voronoi Diagram Computational Geometry Prof. Dr. Th. Ottmann Voronoi Diagrams Definition Characteristics Size and Storage Construction Use.
Chapter 4 Divide-and-Conquer Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
2 -1 Chapter 2 The Complexity of Algorithms and the Lower Bounds of Problems.
3 -1 Chapter 3 The Greedy Method 3 -2 The greedy method Suppose that a problem can be solved by a sequence of decisions. The greedy method has that each.
Chapter 4: Divide and Conquer The Design and Analysis of Algorithms.
Prune-and-search Strategy
5 - 1 § 5 The Divide-and-Conquer Strategy e.g. find the maximum of a set S of n numbers.
Administrivia, Lecture 5 HW #2 was assigned on Sunday, January 20. It is due on Thursday, January 31. –Please use the correct edition of the textbook!
2 -1 Chapter 2 The Complexity of Algorithms and the Lower Bounds of Problems.
Design and Analysis of Algorithms - Chapter 41 Divide and Conquer The most well known algorithm design strategy: 1. Divide instance of problem into two.
9-1 Chapter 9 Approximation Algorithms. 9-2 Approximation algorithm Up to now, the best algorithm for solving an NP-complete problem requires exponential.
The Complexity of Algorithms and the Lower Bounds of Problems
UNC Chapel Hill M. C. Lin Point Location Chapter 6 of the Textbook –Review –Algorithm Analysis –Dealing with Degeneracies.
Delaunay Triangulations Presented by Glenn Eguchi Computational Geometry October 11, 2001.
Voronoi Diagram and Delaunay Triangulation
© The McGraw-Hill Companies, Inc., Chapter 3 The Greedy Method.
2 -1 Chapter 2 The Complexity of Algorithms and the Lower Bounds of Problems.
Convex Hull. What is the Convex Hull? Imagine a set of points on a board with a nail hammered into each point. Now stretch a rubber band over all the.
A. Levitin “Introduction to the Design & Analysis of Algorithms,” 3rd ed., Ch. 5 ©2012 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved.
© The McGraw-Hill Companies, Inc., Chapter 6 Prune-and-Search Strategy.
Divide and Conquer Andreas Klappenecker [based on slides by Prof. Welch]
1 Prune-and-Search Method 2012/10/30. A simple example: Binary search sorted sequence : (search 9) step 1  step 2  step 3  Binary search.
Divide and Conquer Andreas Klappenecker [based on slides by Prof. Welch]
4-3~ 鄭力瑋. concave polygon:convex polygon: Convex polygons 「凸」的定義是:圖形內任意兩點的連線不會經過圖形外部。
COMPUTATIONAL GEOMETRY AND MATRIX MULTIPLICATION Mohammed Zeeshan Farooqui Minhaj Uddin.
Convex Hull 2012/10/23. Convex vs. Concave A polygon P is convex if for every pair of points x and y in P, the line xy is also in P; otherwise, it is.
Common Intersection of Half-Planes in R 2 2 PROBLEM (Common Intersection of half- planes in R 2 ) Given n half-planes H 1, H 2,..., H n in R 2 compute.
Polygon Triangulation
Advanced Algorithms Analysis and Design
Lecture 3: Parallel Algorithm Design
CSCE350 Algorithms and Data Structure
Algorithm design techniques Dr. M. Gavrilova
CSCE 411 Design and Analysis of Algorithms
The Divide-and-Conquer Strategy
The Divide-and-Conquer Strategy
Presentation transcript:

5 -1 Chapter 5 The Divide-and-Conquer Strategy

5 -2 A simple example finding the maximum of a set S of n numbers

5 -3 Time complexity: Calculation of T(n): Assume n = 2 k, T(n)= 2T(n/2)+1 = 2(2T(n/4)+1)+1 = 4T(n/4)+2+1 : =2 k-1 T(2)+2 k-2 + … =2 k-1 +2 k-2 + … =2 k -1 = n-1 Time complexity

5 -4 A general divide-and-conquer algorithm Step 1: If the problem size is small, solve this problem directly; otherwise, split the original problem into 2 sub-problems with equal sizes. Step 2: Recursively solve these 2 sub-problems by applying this algorithm. Step 3: Merge the solutions of the 2 sub- problems into a solution of the original problem.

5 -5 Time complexity of the general algorithm Time complexity: where S(n) : time for splitting M(n) : time for merging b : a constant c : a constant e.g. Binary search e.g. quick sort e.g. merge sort

D maxima finding problem Def : A point (x 1, y 1 ) dominates (x 2, y 2 ) if x 1 > x 2 and y 1 > y 2. A point is called a maxima if no other point dominates it Straightforward method : Compare every pair of points. Time complexity: O(n 2 )

5 -7 Divide-and-conquer for maxima finding The maximal points of S L and S R

5 -8 The algorithm: Input: A set of n planar points. Output: The maximal points of S. Step 1: If S contains only one point, return it as the maxima. Otherwise, find a line L perpendicular to the X-axis which separates the set of points into two subsets S L and S R, each of which consisting of n/2 points. Step 2: Recursively find the maximal points of S L and S R. Step 3: Find the largest y-value of S R. Project the maximal points of S L onto L. Discard each of the maximal points of S L if its y-value is less than the largest y-value of S R.

5 -9 Time complexity: T(n) Step 1: O(n) Step 2: 2T(n/2) Step 3: O(n) Assume n = 2 k T(n) = O(n log n)

5 -10 The closest pair problem Given a set S of n points, find a pair of points which are closest together. 1-D version : Solved by sorting Time complexity : O(n log n)  2-D version

5 -11 at most 6 points in area A:

5 -12 The algorithm: Input: A set of n planar points. Output: The distance between two closest points. Step 1: Sort points in S according to their y- values and x-values. Step 2: If S contains only two points, return infinity as their distance. Step 3: Find a median line L perpendicular to the X-axis to divide S into two subsets, with equal sizes, S L and S R. Step 4: Recursively apply Step 2 and Step 3 to solve the closest pair problems of S L and S R. Let d L (d R ) denote the distance between the closest pair in S L (S R ). Let d = min(d L, d R ).

5 -13 Step 5: For a point P in the half-slab bounded by L-d and L, let its y-value by denoted as y P. For each such P, find all points in the half- slab bounded by L and L+d whose y-value fall within y P +d and y P -d. If the distance d between P and a point in the other half-slab is less than d, let d=d. The final value of d is the answer. Time complexity: O(n log n) Step 1: O(n log n) Steps 2~5:  T(n) = O(n log n)

5 -14 The convex hull problem The convex hull of a set of planar points is the smallest convex polygon containing all of the points. concave polygon:convex polygon:

5 -15 The divide-and-conquer strategy to solve the problem:

5 -16 The merging procedure: 1.Select an interior point p. 2.There are 3 sequences of points which have increasing polar angles with respect to p. (1) g, h, i, j, k (2) a, b, c, d (3) f, e 3.Merge these 3 sequences into 1 sequence: g, h, a, b, f, c, e, d, i, j, k. 4.Apply Graham scan to examine the points one by one and eliminate the points which cause reflexive angles. (See the example on the next page.)

5 -17 e.g. points b and f need to be deleted. Final result:

5 -18 Divide-and-conquer for convex hull Input : A set S of planar points Output : A convex hull for S Step 1: If S contains no more than five points, use exhaustive searching to find the convex hull and return. Step 2: Find a median line perpendicular to the X-axis which divides S into S L and S R ; S L lies to the left of S R. Step 3: Recursively construct convex hulls for S L and S R. Denote these convex hulls by Hull(S L ) and Hull(S R ) respectively.

5 -19 Step 4: Apply the merging procedure to merge Hull(S L ) and Hull(S R ) together to form a convex hull. Time complexity: T(n) = 2T(n/2) + O(n) = O(n log n)

5 -20 The Voronoi diagram problem e.g. The Voronoi diagram for three points Each L ij is the perpendicular bisector of the line.

5 -21 Definition of Voronoi diagrams Def : Given two points P i, P j  S, let H(P i,P j ) denote the half plane containing P i. The Voronoi polygon associated with P i is defined as

5 -22 Given a set of n points, the Voronoi diagram consists of all the Voronoi polygons of these points. The vertices of the Voronoi diagram are called Voronoi points and its segments are called Voronoi edges.

5 -23 Delaunay triangulation

5 -24 Example for constructing Voronoi diagrams Divide the points into two parts.

5 -25 Merging two Voronoi diagrams Merging along the piecewise linear hyperplane

5 -26 After merging The final Voronoi diagram

5 -27 Divide-and-conquer for Voronoi diagram Input: A set S of n planar points. Output: The Voronoi diagram of S. Step 1: If S contains only one point, return. Step 2: Find a median line L perpendicular to the X-axis which divides S into S L and S R such that S L (S R ) lies to the left(right) of L and the sizes of S L and S R are equal.

5 -28 Step 3: Construct Voronoi diagrams of S L and S R recursively. Denote these Voronoi diagrams by VD(S L ) and VD(S R ). Step 4: Construct a dividing piece-wise linear hyperplane HP which is the locus of points simultaneously closest to a point in S L and a point in S R. Discard all segments of VD(S L ) which lie to the right of HP and all segments of VD(S R ) that lie to the left of HP. The resulting graph is the Voronoi diagram of S. (See details on the next page.)

5 -29 Mergeing Two Voronoi Diagrams into One Voronoi Diagram Input: (a) S L and S R where S L and S R are divided by a perpendicular line L. (b) VD(S L ) and VD(S R ). Output: VD(S) where S = S L ∩ S R Step 1: Find the convex hulls of S L and S R, denoted as Hull(S L ) and Hull(S R ), respectively. (A special algorithm for finding a convex hull in this case will by given later.)

5 -30 Step 2: Find segments and which join HULL(S L ) and HULL(S R ) into a convex hull (P a and P c belong to S L and P b and P d belong to S R ) Assume that lies above. Let x = a, y = b, SG= and HP = . Step 3: Find the perpendicular bisector of SG. Denote it by BS. Let HP = HP ∪ {BS}. If SG =, go to Step 5; otherwise, go to Step 4.

5 -31 Step 4: The ray from VD(S L ) and VD(S R ) which BS first intersects with must be a perpendicular bisector of either or for some z. If this ray is the perpendicular bisector of, then let SG = ; otherwise, let SG =. Go to Step 3. Step 5: Discard the edges of VD(S L ) which extend to the right of HP and discard the edges of VD(S R ) which extend to the left of HP. The resulting graph is the Voronoi diagram of S = S L ∪ S R.

5 -32 Properties of Voronoi Diagrams Def : Given a point P and a set S of points, the distance between P and S is the distance between P and P i which is the nearest neighbor of P in S. The HP obtained from the above algorithm is the locus of points which keep equal distances to S L and S R. The HP is monotonic in y.

5 -33 # of edges of a Voronoi diagram  3n - 6, where n is # of points. Reasoning: i.# of edges of a planar graph with n vertices  3n - 6. ii.A Delaunay triangulation is a planar graph. iii.Edges in Delaunay triangulation edges in Voronoi diagram. # of Voronoi edges

5 -34 # of Voronoi vertices # of Voronoi vertices  2n - 4. Reasoning : i.Let F, E and V denote # of face, edges and vertices in a planar graph. Euler ’ s relation: F = E - V + 2. ii.In a Delaunay triangulation, V = n, E  3n – 6  F = E - V + 2  3n n + 2 = 2n - 4.

5 -35 Construct a convex hull from a Voronoi diagram After a Voronoi diagram is constructed, a convex hull can by found in O(n) time.

5 -36 Construct Convex Hull from Voronoi diagram Step 1: Find an infinite ray by examining all Voronoi edges. Step 2: Let P i be the point to the left of the infinite ray. P i is a convex hull vertex. Examine the Voronoi polygon of P i to find the next infinite ray. Step 3: Repeat Step 2 until we return to the Starting ray.

5 -37 Time complexity Time complexity for merging 2 Voronoi diagrams: Total: O(n) Step 1: O(n) Step 2: O(n) Step 3 ~ Step 5: O(n) (at most 3n - 6 edges in VD(S L ) and VD(S R ) and at most n segments in HP) Time complexity for constructing a Voronoi diagram: O(n log n) because T(n) = 2T(n/2) + O(n)=O(n log n)

5 -38 Lower bound The lower bound of the Voronoi diagram problem is  (n log n). sorting  Voronoi diagram problem The Voronoi diagram for a set of points on a straight line

5 -39 Applications of Voronoi diagrams The Euclidean nearest neighbor searching problem. The Euclidean all nearest neighbor problem.

5 -40 Fast Fourier transform (FFT) Fourier transform A(f) = a(t)e 2  ift dt Inverse Fourier transform a(t) = A(f)e -2  ift df Discrete Fourier transform(DFT) Given a 0, a 1, …, a n-1 A j = a k e 2  ijk/n,0  j  n-1 Inverse DFT a k = A j e -2  ijk/n,0  k  n-1

5 -41 DFT and waveform Any periodic waveform can be decomposed into the linear sum of sinusoid functions (sine or cosine). See the left part:

5 -42 An application of the FFT  polynomial multiplication Polynomial multiplication: The straightforward product requires O(n 2 ) time. DFT notations:

5 -43 Fast polynomial multiplication Step 1: Let N be the smallest integer that N=2 q and N  2n-1. Step 2: Compute FFT of Step 3: Compute FFT of Step 4: Step 5: Time complexity: O(NlogN)=O(nlogn), N<4n.

5 -44 FFT algorithm A straightforward method to calculate DFT requires O(n 2 ) time. DFT can be solved by the divide-and-conquer strategy (FFT). Let w=e 2  i/n. i.e. w n =1, w n/2 =-1. A j = a k e 2  ijk/n, 0  j  n-1 = a k w jk e.g. n = 8, let e 2  i/8 = w= e  i/4

5 -45 FFT algorithm when n=4 n =4, let e 2  i/4 =w = e  i/2 (w 4 = 1, w 2 = -1) A 0 = a 0 + a 1 + a 2 + a 3 A 1 = a 0 + a 1 w + a 2 w 2 + a 3 w 3 A 2 = a 0 + a 1 w 2 + a 2 w (2)(2) + a 3 w (2)(3) = a 0 + a 1 w 2 + a 2 w 4 + a 3 w 6 A 3 = a 0 + a 1 w 3 + a 2 w (3)(2) + a 3 w (3)(3) = a 0 + a 1 w 3 + a 2 w 6 + a 3 w 9

5 -46 Rewrite as: A 0 = a 0 + a 2 + (a 1 + a 3 ) A 2 = a 0 + a 2 w 4 + (a 1 w 2 + a 3 w 6 ) = a 0 + a 2 - (a 1 + a 3 ) When we calculate A 0, we shall calculate (a 0 + a 2 ) and (a 1 + a 3 ). Later, A 2 can be easily found. Similarly, A 1 = (a 0 + a 2 w 2 ) + a 1 w + a 3 w 3 A 3 = (a 0 + a 2 w 6 ) + (a 1 w 3 + a 3 w 9 ) = (a 0 + a 2 w 2 ) - (a 1 w + a 3 w 3 )

5 -47 n = 8, let e 2  i/8 = w = e  i/4 (w 8 = 1, w 4 = -1) A 0 = a 0 + a 1 + a 2 + a 3 + a 4 + a 5 + a 6 + a 7 A 1 = a 0 +a 1 w+a 2 w 2 +a 3 w 3 +a 4 w 4 +a 5 w 5 +a 6 w 6 +a 7 w 7 A 2 = a 0 +a 1 w 2 +a 2 w 4 +a 3 w 6 +a 4 w 8 +a 5 w 10 +a 6 w 12 +a 7 w 14 A 3 = a 0 +a 1 w 3 +a 2 w 6 +a 3 w 9 +a 4 w 12 +a 5 w 15 +a 6 w 18 +a 7 w 21 A 4 = a 0 +a 1 w 4 +a 2 w 8 +a 3 w 12 +a 4 w 16 +a 5 w 20 +a 6 w 24 +a 7 w 28 A 5 = a 0 +a 1 w 5 +a 2 w 10 +a 3 w 15 +a 4 w 20 +a 5 w 25 +a 6 w 30 +a 7 w 35 A 6 = a 0 +a 1 w 6 +a 2 w 12 +a 3 w 18 +a 4 w 24 +a 5 w 30 +a 6 w 36 +a 7 w 42 A 7 = a 0 +a 1 w 7 +a 2 w 14 +a 3 w 21 +a 4 w 28 +a 5 w 35 +a 6 w 42 +a 7 w 49 FFT algorithm when n=8

5 -48 After reordering, we have A 0 =(a 0 +a 2 +a 4 +a 6 )+(a 1 +a 3 +a 5 +a 7 ) A 4 =(a 0 +a 2 +a 4 +a 6 )-(a 1 +a 3 +a 5 +a 7 ) A 1 =(a 0 +a 2 w 2 +a 4 w 4 +a 6 w 6 )+w(a 1 +a 3 w 2 +a 5 w 4 +a 7 w 6 ) A 5 =(a 0 +a 2 w 2 +a 4 w 4 +a 6 w 6 )-w(a 1 +a 3 w 2 +a 5 w 4 +a 7 w 6 ) A 2 =(a 0 +a 2 w 4 +a 4 w 8 +a 6 w 12 )+w 2 (a 1 +a 3 w 4 +a 5 w 8 +a 7 w 12 ) A 6 =(a 0 +a 2 w 4 +a 4 w 8 +a 6 w 12 )-w 2 (a 1 +a 3 w 4 +a 5 w 8 +a 7 w 12 ) A 3 =(a 0 +a 2 w 6 +a 4 w 12 +a 6 w 18 )+w 3 (a 1 +a 3 w 6 +a 5 w 9 +a 7 w 18 ) A 7 =(a 0 +a 2 w 6 +a 4 w 12 +a 6 w 18 )-w 3 (a 1 +a 3 w 6 +a 5 w 9 +a 7 w 18 ) Rewrite as: A 0 = B 0 + C 0 A 4 = B 0 - C 0 A 1 = B 1 + C 1 A 5 = B 1 - C 1 A 2 = B 2 + C 2 A 6 = B 2 - C 2 A 3 = B 3 + C 3 A 7 = B 3 - C 3

5 -49 let x=w 2 =e 2  i/4 = e  i/2 (x 4 = 1, x 2 = -1) We can recursively apply the same method to calculate B i ’ s and C i ’ s. B 0 = a 0 +a 2 +a 4 +a 6 B 1 = a 0 +a 2 w 2 +a 4 w 4 +a 6 w 6 = a 0 +a 2 x+a 4 x 2 +a 6 x 3 B 2 = a 0 +a 2 w 4 +a 4 w 8 +a 6 w 12 = a 0 +a 2 x 2 +a 4 x 4 +a 6 x 6 B 3 = a 0 +a 2 w 6 +a 4 w 12 +a 6 w 18 = a 0 +a 2 x 3 +a 4 x 6 +a 6 x 9 Thus, {B 0, B 1, B 2, B 3 } is the DFT of {a 0, a 1, a 2, a 3 }.

5 -50 General FFT In general, let w = e 2  i/n (assume n is even) (w n = 1, w n/2 = -1) A j = a 0 +a 1 w j +a 2 w 2j + … +a n-1 w (n-1)j ={a 0 +a 2 w 2j +a 4 w 4j + … +a n-2 w (n-2)j } + {a 1 w j +a 3 w 3j + … +a n-1 w (n-1)j } = B j + C j A j+n/2 = a 0 +a 1 w j+n/2 +a 2 w 2j+n +a 3 w 3j+3n/2 + … + a n-1 w (n-1)j+(n(n-1)/2) =a 0 -a 1 w j +a 2 w 2j -a 3 w 3j + … +a n-2 w (n-2)j -a n-1 w (n-1)j = B j - C j

5 -51 Divide-and-conquer (FFT) Input : a 0, a 1, …, a n-1, n = 2 k Output : A j, j=0, 1, 2, …, n-1, where A j =  0  k  n-1 a k e 2  ijk/n Step 1: If n=2, compute A 0 = a 0 + a 1, A 1 = a 0 - a 1, and return. Step 2: Divide each a j, 0  j  n/2 - 1 into two sequences: O j and E j, where O j (E j ), consists of odd-numbered (even-numbered) terms of A j.

5 -52 Step 3: Recursively calculate the sums of terms in O j and E j. Denote the sum of terms of O j and E j by B j and C j, respectively. Step 4: Compute A j by the following formual : A j = B j + C j for 0  j  n/2 - 1 A j +n/2 = B j - C j for 0  j  n/ Time complexity : T(n) = 2T(n/2) + O(n) = O(n log n)

5 -53 Matrix multiplication Let A, B and C be n  n matrices C = AB C(i, j) = A(i, k)B(k, j) The straightforward method to perform a matrix multiplication requires O(n 3 ) time.

5 -54 Divide-and-conquer approach C = AB 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 11 + A 22 B 21 C 22 = A 21 B 12 + A 22 B 22 Time complexity: (# of additions : n 2 ) We get T(n) = O(n 3 )

5 -55 P = (A 11 + A 22 )(B 11 + B 22 ) Q = (A 21 + A 22 )B 11 R = A 11 (B 12 - B 22 ) S = A 22 (B 21 - B 11 ) T = (A 11 + A 12 )B 22 U = (A 21 - A 11 )(B 11 + B 12 ) V = (A 12 - A 22 )(B 21 + B 22 ). C 11 = P + S - T + V C 12 = R + T C 21 = Q + S C 22 = P + R - Q + U Strassen ’ s matrix multiplicaiton

5 -56 Time complexity 7 multiplications and 18 additions or subtractions Time complexity: T(n) = an 2 + 7T(n/2) = an 2 + 7(a(n/2) 2 + 7T(n/4)) = an 2 + (7/4)an T(n/4) = … : = an 2 (1 + 7/4 + (7/4) 2 + … +(7/4) k-1 +7 k T(1))  cn 2 (7/4) log2n +7 log2n, c is a constant = cn log24+log27-log24 +n log27 = O(n log27 )  O(n 2.81 )