lecture_03

# lecture_03 - Introduction to Algorithms 6.046J/18.401J...

This preview shows pages 1–12. Sign up to view the full content.

Introduction to Algorithms 6.046J/18.401J Prof. Charles E. Leiserson L ECTURE 3 Divide and conquer Binary search Powering a number Fibonacci numbers Matrix multiplication Strassen’s algorithm VLSI tree layout

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

View Full Document
September 15, 2004 Introduction to Algorithms L3.2 The divide-and-conquer design paradigm 1. Divide the problem (instance) into subproblems. 2. Conquer the subproblems by solving them recursively. 3. Combine subproblem solutions. © 2001–4 by Charles E. Leiserson
September 15, 2004 Introduction to Algorithms L3.3 Merge sort 1. Divide: Trivial. 2. Conquer: Recursively sort 2 subarrays. 3. Combine: Linear-time merge. © 2001–4 by Charles E. Leiserson

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

View Full Document
September 15, 2004 Introduction to Algorithms L3.4 Merge sort 1. Divide: Trivial. 2. Conquer: Recursively sort 2 subarrays. 3. Combine: Linear-time merge. T ( n ) = 2 T ( n /2) + Θ ( n ) # subproblems subproblem size work dividing and combining © 2001–4 by Charles E. Leiserson
September 15, 2004 Introduction to Algorithms L3.5 Master theorem (reprise) T ( n ) = aT ( n / b ) + f ( n ) C ASE 1 : f ( n ) = O ( n log b a ε ) , constant ε > 0 T ( n ) = Θ ( n log b a ) . C ASE 2 : f ( n ) = Θ ( n log b a lg k n ) , constant k 0 T ( n ) = Θ ( n log b a lg k +1 n ) . C ASE 3 : f ( n ) = ( n log b a + ε ) , constant ε > 0 , and regularity condition T ( n ) = Θ ( f ( n )) . © 2001–4 by Charles E. Leiserson

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

View Full Document
September 15, 2004 Introduction to Algorithms L3.6 Master theorem (reprise) T ( n ) = aT ( n / b ) + f ( n ) C ASE 1 : f ( n ) = O ( n log b a ε ) , constant ε > 0 T ( n ) = Θ ( n log b a ) . C ASE 2 : f ( n ) = Θ ( n log b a lg k n ) , constant k 0 T ( n ) = Θ ( n log b a lg k +1 n ) . C ASE 3 : f ( n ) = ( n log b a + ε ) , constant ε > 0 , and regularity condition T ( n ) = Θ ( f ( n )) . Merge sort: a = 2 , b = 2 n log b a = n log 2 2 = n C ASE 2 ( k = 0 ) T ( n ) = Θ ( n lg n ) . © 2001–4 by Charles E. Leiserson
September 15, 2004 Introduction to Algorithms L3.7 Binary search Find an element in a sorted array: 1. Divide: Check middle element. 2. Conquer: Recursively search 1 subarray. 3. Combine: Trivial. © 2001–4 by Charles E. Leiserson

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

View Full Document
September 15, 2004 Introduction to Algorithms L3.8 Binary search Example: Find 9 35789 1 2 1 5 Find an element in a sorted array: 1. Divide: Check middle element. 2. Conquer: Recursively search 1 subarray. 3. Combine: Trivial. © 2001–4 by Charles E. Leiserson
September 15, 2004 Introduction to Algorithms L3.9 Binary search Example: Find 9 35789 1 2 1 5 Find an element in a sorted array: 1. Divide: Check middle element. 2. Conquer: Recursively search 1 subarray. 3. Combine: Trivial. © 2001–4 by Charles E. Leiserson

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

View Full Document
September 15, 2004 Introduction to Algorithms L3.10 Binary search Example: Find 9 35789 1 2 1 5 Find an element in a sorted array: 1. Divide: Check middle element. 2. Conquer: Recursively search 1 subarray. 3. Combine: Trivial. © 2001–4 by Charles E. Leiserson
September 15, 2004 Introduction to Algorithms L3.11 Binary search Example: Find 9 35789 1 2 1 5 Find an element in a sorted array: 1. Divide: Check middle element.

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 04/10/2008 for the course CSE 6.046J/18. taught by Professor Piotrindykandcharlese.leiserson during the Fall '04 term at MIT.

### Page1 / 54

lecture_03 - Introduction to Algorithms 6.046J/18.401J...

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

View Full Document
Ask a homework question - tutors are online