lecture_11

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

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

Introduction to Algorithms 6.046J/18.401J Prof. Charles E. Leiserson L ECTURE 11 Amortized analysis Dynamic tables Aggregate method Accounting method Potential method

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

View Full Document
Introduction to Algorithms October 20, 2004 L14.2 © 2001–4 by Charles E. Leiserson How large should a hash table be? Problem: What if we don’t know the proper size in advance? Goal: Make the table as small as possible, but large enough so that it won’t overflow (or otherwise become inefficient). I DEA : Whenever the table overflows, “grow” it by allocating (via malloc or new ) a new, larger table. Move all items from the old table into the new one, and free the storage for the old table. Solution: Dynamic tables.
Introduction to Algorithms October 20, 2004 L14.3 © 2001–4 by Charles E. Leiserson Example of a dynamic table 1. I NSERT 1 2. I NSERT overflow

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

View Full Document
Introduction to Algorithms October 20, 2004 L14.4 © 2001–4 by Charles E. Leiserson 1 1 Example of a dynamic table 1. I NSERT 2. I NSERT overflow
Introduction to Algorithms October 20, 2004 L14.5 © 2001–4 by Charles E. Leiserson 1 1 2 Example of a dynamic table 1. I NSERT 2. I NSERT

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

View Full Document
Introduction to Algorithms October 20, 2004 L14.6 © 2001–4 by Charles E. Leiserson Example of a dynamic table 1. I NSERT 2. I NSERT 1 1 2 2 3. I NSERT overflow
Introduction to Algorithms October 20, 2004 L14.7 © 2001–4 by Charles E. Leiserson Example of a dynamic table 1. I NSERT 2. I NSERT 3. I NSERT 2 1 overflow

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

View Full Document
Introduction to Algorithms October 20, 2004 L14.8 © 2001–4 by Charles E. Leiserson Example of a dynamic table 1. I NSERT 2. I NSERT 3. I NSERT 2 1
Introduction to Algorithms October 20, 2004 L14.9 © 2001–4 by Charles E. Leiserson Example of a dynamic table 1. I NSERT 2. I NSERT 3. I NSERT 4. I NSERT 4 3 2 1

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

View Full Document
Introduction to Algorithms October 20, 2004 L14.10 © 2001–4 by Charles E. Leiserson Example of a dynamic table 1. I NSERT 2. I NSERT 3. I NSERT 4. I NSERT 5. I NSERT 4 3 2 1 overflow
Introduction to Algorithms October 20, 2004 L14.11 © 2001–4 by Charles E. Leiserson Example of a dynamic table 1. I NSERT 2. I NSERT 3. I NSERT 4. I NSERT 5. I NSERT 4 3 2 1 overflow

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

View Full Document
Introduction to Algorithms October 20, 2004 L14.12 © 2001–4 by Charles E. Leiserson Example of a dynamic table 1. I NSERT 2. I NSERT 3. I NSERT 4. I NSERT 5. I NSERT 4 3 2 1
Introduction to Algorithms October 20, 2004 L14.13 © 2001–4 by Charles E. Leiserson Example of a dynamic table 1. I NSERT 2. I NSERT 3. I NSERT 4. I NSERT 6. I NSERT 6 5. I NSERT 5 4 3 2 1 7 7. I NSERT

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

View Full Document
Introduction to Algorithms October 20, 2004 L14.14 © 2001–4 by Charles E. Leiserson Worst-case analysis Consider a sequence of n insertions. The
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 / 34

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

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

View Full Document
Ask a homework question - tutors are online