Introduction to Algorithms

Slides:



Advertisements
Similar presentations
Divide-and-Conquer CIS 606 Spring 2010.
Advertisements

A simple example finding the maximum of a set S of n numbers.
More on Divide and Conquer. The divide-and-conquer design paradigm 1. Divide the problem (instance) into subproblems. 2. Conquer the subproblems by solving.
Introduction to Algorithms Jiafen Liu Sept
1 Divide-and-Conquer CSC401 – Analysis of Algorithms Lecture Notes 11 Divide-and-Conquer Objectives: Introduce the Divide-and-conquer paradigm Review the.
Introduction to Algorithms 6.046J/18.401J L ECTURE 3 Divide and Conquer Binary search Powering a number Fibonacci numbers Matrix multiplication Strassen’s.
Lecture 2: Divide and Conquer algorithms Phan Thị Hà Dương
Divide and Conquer. Recall Complexity Analysis – Comparison of algorithm – Big O Simplification From source code – Recursive.
Nattee Niparnan. Recall  Complexity Analysis  Comparison of Two Algos  Big O  Simplification  From source code  Recursive.
CS Section 600 CS Section 002 Dr. Angela Guercio Spring 2010.
Divide-and-Conquer1 7 2  9 4   2  2 79  4   72  29  94  4.
Divide-and-Conquer1 7 2  9 4   2  2 79  4   72  29  94  4.
Data Structures, Spring 2004 © L. Joskowicz 1 Data Structures – LECTURE 3 Recurrence equations Formulating recurrence equations Solving recurrence equations.
Data Structures, Spring 2006 © L. Joskowicz 1 Data Structures – LECTURE 3 Recurrence equations Formulating recurrence equations Solving recurrence equations.
Recurrences The expression: is a recurrence. –Recurrence: an equation that describes a function in terms of its value on smaller functions Analysis of.
CSE 421 Algorithms Richard Anderson Lecture 11 Recurrences.
Unit 1. Sorting and Divide and Conquer. Lecture 1 Introduction to Algorithm and Sorting.
Recurrences The expression: is a recurrence. –Recurrence: an equation that describes a function in terms of its value on smaller functions BIL741: Advanced.
Arithmetic.
Divide-and-Conquer 7 2  9 4   2   4   7
Introduction to Algorithms 6.046J/18.401J/SMA5503 Lecture 3 Prof. Erik Demaine.
Data Structures and Algorithms A. G. Malamos
Project 2 due … Project 2 due … Project 2 Project 2.
9/10/10 A. Smith; based on slides by E. Demaine, C. Leiserson, S. Raskhodnikova, K. Wayne Adam Smith Algorithm Design and Analysis L ECTURES Divide.
Divide and Conquer Andreas Klappenecker [based on slides by Prof. Welch]
1 Chapter 4 Divide-and-Conquer. 2 About this lecture Recall the divide-and-conquer paradigm, which we used for merge sort: – Divide the problem into a.
ADA: 4.5. Matrix Mult.1 Objective o an extra divide and conquer example, based on a question in class Algorithm Design and Analysis (ADA) ,
Divide and Conquer Andreas Klappenecker [based on slides by Prof. Welch]
Divide and Conquer. Recall Divide the problem into a number of sub-problems that are smaller instances of the same problem. Conquer the sub-problems by.
Divide and Conquer Faculty Name: Ruhi Fatima Topics Covered Divide and Conquer Matrix multiplication Recurrence.
CMPT 438 Algorithms.
Introduction to Algorithms: Divide-n-Conquer Algorithms
Introduction to Algorithms
Introduction to Algorithms Prof. Charles E. Leiserson
Divide-and-Conquer 6/30/2018 9:16 AM
Unit 1. Sorting and Divide and Conquer
CS 3343: Analysis of Algorithms
Chapter 4: Divide and Conquer
Introduction to the Design and Analysis of Algorithms
Lecture 4 Divide-and-Conquer
Divide-and-Conquer The most-well known algorithm design strategy:
Chapter 4 Divide-and-Conquer
Divide-and-Conquer The most-well known algorithm design strategy:
CSCE 411 Design and Analysis of Algorithms
CS 3343: Analysis of Algorithms
CS 3343: Analysis of Algorithms
Introduction to Algorithms 6.046J
Richard Anderson Lecture 13 Recurrences and Divide and Conquer
Divide-and-Conquer 7 2  9 4   2   4   7
CS 3343: Analysis of Algorithms
Lecture 6 More Divide-Conquer and Paradigm #4 Data Structure.
Richard Anderson Lecture 12 Recurrences and Divide and Conquer
Divide-and-Conquer The most-well known algorithm design strategy:
CSE 2010: Algorithms and Data Structures
Divide and Conquer Algorithms Part I
Introduction to Algorithms
Divide-and-Conquer The most-well known algorithm design strategy:
Divide and Conquer (Merge Sort)
Divide-and-Conquer 7 2  9 4   2   4   7
CSC 380: Design and Analysis of Algorithms
CSC 380: Design and Analysis of Algorithms
Lecture 30 CSE 331 Nov 12, 2012.
Richard Anderson Lecture 14 Divide and Conquer
Algorithms Recurrences.
Topic: Divide and Conquer
Richard Anderson Lecture 14, Winter 2019 Divide and Conquer
Divide-and-Conquer 7 2  9 4   2   4   7
Divide-and-conquer approach
Divide and Conquer Merge sort and quick sort Binary search
Presentation transcript:

Introduction to Algorithms 6.046J/18.401J LECTURE 3 Divide and Conquer Binary search Powering a number Fibonacci numbers Matrix multiplication Strassen’s algorithm VLSI tree layout Prof. Erik D. Demaine Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson September 14, 2005 L2.1

The divide-and-conquer design paradigm Divide the problem (instance) into subproblems. Conquer the subproblems by solving them recursively. Combine subproblem solutions. September 14, 2005 Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson L2.2

Merge sort Divide: Trivial. Conquer: Recursively sort 2 subarrays. Combine: Linear-time merge. September 14, 2005 Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson L2.3

Merge sort Divide: Trivial. Conquer: Recursively sort 2 subarrays. Combine: Linear-time merge. T(n) = 2 T(n/2) + (n) # subproblems subproblem size work dividing and combining September 14, 2005 Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson L2.4

Master theorem (reprise) T(n) = a T(n/b) + f (n) CASE 1: f (n) = O(nlogba – ), constant  > 0  T(n) = (nlogba) . CASE 2: f (n) = (nlogba lgkn), constant k  0  T(n) = (nlogba lgk+1n) . CASE 3: f (n) = (nlogba +  ), constant  > 0, and regularity condition  T(n) = ( f (n)) . September 14, 2005 Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson L2.5

Master theorem (reprise) T(n) = a T(n/b) + f (n) CASE 1: f (n) = O(nlogba – ), constant  > 0  T(n) = (nlogba) . CASE 2: f (n) = (nlogba lgkn), constant k  0  T(n) = (nlogba lgk+1n) . CASE 3: f (n) = (nlogba +  ), constant  > 0, and regularity condition  T(n) = ( f (n)) . Merge sort: a = 2, b = 2  nlogba = nlog22 = n  CASE 2 (k = 0)  T(n) = (n lg n) . September 14, 2005 Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson L2.6

Binary search Find an element in a sorted array: Divide: Check middle element. Conquer: Recursively search 1 subarray. Combine: Trivial. September 14, 2005 Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson L2.7

Binary search Find an element in a sorted array: Divide: Check middle element. Conquer: Recursively search 1 subarray. Combine: Trivial. Example: Find 9 3 5 7 8 9 12 15 September 14, 2005 Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson L2.8

Binary search Find an element in a sorted array: Divide: Check middle element. Conquer: Recursively search 1 subarray. Combine: Trivial. Example: Find 9 3 5 7 8 9 12 15 September 14, 2005 Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson L2.9

Binary search Find an element in a sorted array: Divide: Check middle element. Conquer: Recursively search 1 subarray. Combine: Trivial. Example: Find 9 3 5 7 8 9 12 15 September 14, 2005 Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson L2.10

Binary search Find an element in a sorted array: Divide: Check middle element. Conquer: Recursively search 1 subarray. Combine: Trivial. Example: Find 9 3 5 7 8 9 12 15 September 14, 2005 Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson L2.11

Binary search Find an element in a sorted array: Divide: Check middle element. Conquer: Recursively search 1 subarray. Combine: Trivial. Example: Find 9 3 5 7 8 9 12 15 September 14, 2005 Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson L2.12

Binary search Find an element in a sorted array: Divide: Check middle element. Conquer: Recursively search 1 subarray. Combine: Trivial. Example: Find 9 3 5 7 8 9 12 15 September 14, 2005 Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson L2.13

Recurrence for binary search T(n) = 1 T(n/2) + (1) # subproblems subproblem size work dividing and combining September 14, 2005 Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson L2.14

Recurrence for binary search T(n) = 1 T(n/2) + (1) # subproblems subproblem size work dividing and combining nlogba = nlog21 = n0 = 1  CASE 2 (k = 0)  T(n) = (lg n) . September 14, 2005 Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson L2.15

Powering a number Problem: Compute an, where n  N. Naive algorithm: (n). September 14, 2005 Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson L2.16

a n/2  a n/2 a (n–1)/2  a (n–1)/2  a Powering a number Problem: Compute an, where n  N. Naive algorithm: (n). Divide-and-conquer algorithm: a n/2  a n/2 a (n–1)/2  a (n–1)/2  a if n is even; if n is odd. an = September 14, 2005 Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson L2.17

a n/2  a n/2 a (n–1)/2  a (n–1)/2  a Powering a number Problem: Compute an, where n  N. Naive algorithm: (n). Divide-and-conquer algorithm: a n/2  a n/2 a (n–1)/2  a (n–1)/2  a if n is even; if n is odd. an = T(n) = T(n/2) + (1)  T(n) = (lg n) . September 14, 2005 Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson L2.18

Fibonacci numbers Recursive definition: if n = 0; if n = 1; Fn = Fn–1 + Fn–2 if n  2. 0 1 1 2 3 5 8 13 21 34 L Fn = September 14, 2005 Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson L2.19

Fn–1 + Fn–2 Fibonacci numbers 5)/ 2 Recursive definition: if n = 0; if n = 1; if n  2. 0 1 1 2 3 5 8 13 21 34 L 1 Fn–1 + Fn–2 Fn = Naive recursive algorithm: ( n) (exponential time), where  = (1 is the golden ratio. 5)/ 2 September 14, 2005 Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson L2.20

Computing Fibonacci numbers Bottom-up: Compute F0, F1, F2, …, Fn in order, forming each number by summing the two previous. Running time: (n). September 14, 2005 Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson L2.21

Computing Fibonacci numbers Bottom-up: Compute F0, F1, F2, …, Fn in order, forming each number by summing the two previous. Running time: (n). Naive recursive squaring: Fn =  n/ 5 rounded to the nearest integer. Recursive squaring: (lg n) time. This method is unreliable, since floating-point arithmetic is prone to round-off errors. September 14, 2005 Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson L2.22

1⎤n ⎡Fn1 ⎣⎢ F 0⎥⎦ . Recursive squaring Fn ⎤ ⎡1 Theorem: ⎥⎦  ⎢⎣1 F n 0⎥⎦ . ⎥⎦  ⎢⎣1 F n n1 September 14, 2005 Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson L2.23

1⎤n ⎡Fn1 ⎣⎢ F 0⎥⎦ . Recursive squaring Fn ⎤ ⎡1 Theorem: ⎥⎦  ⎢⎣1 F 0⎥⎦ . ⎥⎦  ⎢⎣1 F n n1 Algorithm: Recursive squaring. Time = (lg n) . September 14, 2005 Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson L2.24

1⎤n ⎡Fn1 ⎣⎢ F 0⎥⎦ . 1⎤ 1 ⎢⎣1 0⎥⎦ Recursive squaring Fn ⎤ ⎡1 Theorem: 0⎥⎦ . ⎥⎦  ⎢⎣1 F n n1 Algorithm: Recursive squaring. Time = (lg n) . Proof of theorem. (Induction on n.) 1⎤ 1 F1 ⎤  ⎡1 Base (n = 1): ⎡F2 . ⎢⎣ F F ⎥⎦ ⎢⎣1 0⎥⎦ 1 0 September 14, 2005 Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson L2.25

1. ⎡F F ⎡ F F ⎣ Fn Fn1⎦ ⎣Fn1 Fn2 ⎦ ⎣1 1⎤n1 ⎡1 ⎡1 0⎥⎦ 1⎤n 0⎥⎦ ⎢⎣1 Recursive squaring Inductive step (n  2): 1. ⎡F F ⎤ ⎡ F F ⎤ ⎡1 ⎤ n1 n ⎥  ⎢ n n1 ⎥  ⎢ 0⎥⎦ ⎢ ⎣ Fn Fn1⎦ ⎣Fn1 Fn2 ⎦ ⎣1 1⎤n1 ⎡1 ⎡1 1⎤ 0⎥⎦ 1⎤n 0⎥⎦  ⎢⎣1 ⎢⎣1 0⎥. ⎦ ⎡1  ⎢ ⎣1 September 14, 2005 Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson L2.26

Matrix multiplication Input: A = [aij], B = [bij]. Output: C = [cij] = A B. i, j = 1, 2,… , n. c12 L c1n ⎤ ⎡a11 c22 ⎢ M M O M ⎥ a12 L a1n ⎤ ⎡b11 b12 L b1n ⎤ a22 b22 ⎢ M M O M n2 ⎡c11 ⎥ L b ⎢c21 L c2n ⎥ ⎢a21 L a2n ⎥ ⎢b21 ⎢ ⎥  ⎢ ⎥  ⎢ 2n ⎥ M ⎥ ⎢ M O M ⎥ ⎢c ⎥ ⎢a ⎥ ⎢b ⎥ c L c a L a b L b ⎣ n1 n2 nn ⎦ ⎣ nn ⎦ ⎣ n1 nn ⎦ n1 n2 n cij  aik  bkj k 1 Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson September 14, 2005 L2.27

Standard algorithm for i  1 to n do for j  1 to n do cij  0 for k  1 to n do cij  cij + aik bkj September 14, 2005 Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson L2.28

Standard algorithm for i  1 to n do for j  1 to n do cij  0 for k  1 to n do cij  cij + aik bkj Running time = (n3) September 14, 2005 Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson L2.29

Divide-and-conquer algorithm nn matrix = 22 matrix of (n/2)n/2) submatrices: ⎡r s ⎤  ⎡a b ⎤  ⎡ e f ⎥⎤ h ⎦ B ⎢⎣t u⎥⎦ C = A ⎣⎢c d ⎥⎦ ⎢⎣g  r = ae + bg s = af + bh t = ce + dg u = cf + dh September 14, 2005 8 mults of (n/2)n/2) submatrices 4 adds of (n/2)n/2) submatrices Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson L2.30

Divide-and-conquer algorithm nn matrix = 22 matrix of (n/2)n/2) submatrices: ⎡r s ⎤  ⎡a b ⎤  ⎡ e f ⎥⎤ h ⎦ B ⎢⎣t u⎥⎦ C = A ⎣⎢c d ⎥⎦ ⎢⎣g  r = ae + bg s = af + bh t = ce + dh u = cf + dg September 14, 2005 recursive 8 mults of (n/2)n/2) submatrices ^ 4 adds of (n/2)n/2) submatrices Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson L2.31

Analysis of D&C algorithm T(n) = 8 T(n/2) + (n2) # submatrices submatrix size work adding submatrices September 14, 2005 Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson L2.32

Analysis of D&C algorithm T(n) = 8 T(n/2) + (n2) # submatrices submatrix size work adding submatrices nlogba = nlog28 = n3  CASE 1  T(n) = (n3). September 14, 2005 Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson L2.33

Analysis of D&C algorithm T(n) = 8 T(n/2) + (n2) # submatrices submatrix size work adding submatrices nlogba = nlog28 = n3  CASE 1  T(n) = (n3). No better than the ordinary algorithm. September 14, 2005 Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson L2.34

Strassen’s idea Multiply 22 matrices with only 7 recursive mults. September 14, 2005 Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson L2.35

Strassen’s idea Multiply 22 matrices with only 7 recursive mults. P1 = a  ( f – h) P2 = (a + b)  h P3 = (c + d)  e P4 = d  (g – e) P5 = (a + d)  (e + h) P6 = (b – d)  (g + h) P7 = (a – c)  (e + f ) September 14, 2005 Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson L2.36

Strassen’s idea Multiply 22 matrices with only 7 recursive mults. P1 = a  ( f – h) P2 = (a + b)  h P3 = (c + d)  e P4 = d  (g – e) P5 = (a + d)  (e + h) P6 = (b – d)  (g + h) P7 = (a – c)  (e + f ) r = P5 + P4 – P2 + P6 s = P1 + P2 t = P3 + P4 u = P5 + P1 – P3 – P7 September 14, 2005 Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson L2.37

Strassen’s idea Multiply 22 matrices with only 7 recursive mults. P1 = a  ( f – h) P2 = (a + b)  h P3 = (c + d)  e P4 = d  (g – e) P5 = (a + d)  (e + h) P6 = (b – d)  (g + h) P7 = (a – c)  (e + f ) r = P5 + P4 – P2 + P6 s = P1 + P2 t = P3 + P4 u = P5 + P1 – P3 – P7 7 mults, 18 adds/subs. Note: No reliance on commutativity of mult! 7 mults, 18 adds/subs. Note: No reliance on commutativity of mult! September 14, 2005 Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson L2.38

Strassen’s idea Multiply 22 matrices with only 7 recursive mults. P1 = a  ( f – h) P2 = (a + b)  h P3 = (c + d)  e P4 = d  (g – e) P5 = (a + d)  (e + h) P6 = (b – d)  (g + h) P7 = (a – c)  (e + f ) r = P5 + P4 – P2 + P6 = (a + d) (e + h) + d (g – e) – (a + b) h + (b – d) (g + h) = ae + ah + de + dh + dg –de – ah – bh + bg + bh – dg – dh = ae + bg September 14, 2005 Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson L2.39

Strassen’s algorithm Divide: Partition A and B into (n/2)(n/2) submatrices. Form terms to be multiplied using + and – . Conquer: Perform 7 multiplications of (n/2)(n/2) submatrices recursively. Combine: Form C using + and – on (n/2)(n/2) submatrices. September 14, 2005 Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson L2.40

Strassen’s algorithm Divide: Partition A and B into (n/2)(n/2) submatrices. Form terms to be multiplied using + and – . Conquer: Perform 7 multiplications of (n/2)(n/2) submatrices recursively. Combine: Form C using + and – on (n/2)(n/2) submatrices. T(n) = 7 T(n/2) + (n2) September 14, 2005 Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson L2.41

Analysis of Strassen T(n) = 7 T(n/2) + (n2) September 14, 2005 Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson L2.42

nlogba = nlog27  n2.81 Analysis of Strassen T(n) = 7 T(n/2) + (n2)  CASE 1  T(n) = (nlg 7). September 14, 2005 Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson L2.43

nlogba = nlog27  n2.81 Analysis of Strassen T(n) = 7 T(n/2) + (n2)  CASE 1  T(n) = (nlg 7). The number 2.81 may not seem much smaller than 3, but because the difference is in the exponent, the impact on running time is significant. In fact, Strassen’s algorithm beats the ordinary algorithm on today’s machines for n  32 or so. September 14, 2005 Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson L2.44

Best to date (of theoretical interest only): (n2.376L). Analysis of Strassen T(n) = 7 T(n/2) + (n2) nlogba = nlog27  n2.81  CASE 1  T(n) = (nlg 7). The number 2.81 may not seem much smaller than 3, but because the difference is in the exponent, the impact on running time is significant. In fact, Strassen’s algorithm beats the ordinary algorithm on today’s machines for n  32 or so. Best to date (of theoretical interest only): (n2.376L). September 14, 2005 Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson L2.45

VLSI layout Problem: Embed a complete binary tree with n leaves in a grid using minimal area. September 14, 2005 Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson L2.46

VLSI layout Problem: Embed a complete binary tree with n leaves in a grid using minimal area. W(n) H(n) September 14, 2005 Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson L2.47

VLSI layout Problem: Embed a complete binary tree with n leaves in a grid using minimal area. W(n) H(n) H(n) = H(n/2) + (1) = (lg n) September 14, 2005 Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson L2.48

VLSI layout Problem: Embed a complete binary tree with n leaves in a grid using minimal area. W(n) H(n) H(n) = H(n/2) + (1) = (lg n) W(n) = 2 W(n/2) + (1) = (n) September 14, 2005 Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson L2.49

VLSI layout Problem: Embed a complete binary tree with n leaves in a grid using minimal area. W(n) H(n) H(n) = H(n/2) + (1) W(n) = 2 W(n/2) + (1) = (lg n) = (n) Area = (n lg n) September 14, 2005 Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson L2.50

H-tree embedding L(n) L(n) September 14, 2005 Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson L2.51

H-tree embedding L(n) L(n) L(n/4) (1) L(n/4) September 14, 2005 Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson L2.52

H-tree embedding L(n) L(n) = 2 L(n/4) + (1) = ( n ) Area = (n) September 14, 2005 (1) L(n/4) Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson L2.53

Conclusion Divide and conquer is just one of several powerful techniques for algorithm design. Divide-and-conquer algorithms can be analyzed using recurrences and the master method (so practice this math). The divide-and-conquer strategy often leads to efficient algorithms. September 14, 2005 Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson L2.54