lecture_11

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

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

View Full Document Right Arrow Icon
Introduction to Algorithms 6.046J/18.401J Prof. Charles E. Leiserson L ECTURE 11 Amortized analysis Dynamic tables Aggregate method Accounting method Potential method
Background image of page 1

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

View Full DocumentRight Arrow Icon
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.
Background image of page 2
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
Background image of page 3

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

View Full DocumentRight Arrow Icon
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
Background image of page 4
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
Background image of page 5

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

View Full DocumentRight Arrow Icon
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
Background image of page 6
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
Background image of page 7

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

View Full DocumentRight Arrow Icon
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
Background image of page 8
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
Background image of page 9

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

View Full DocumentRight Arrow Icon
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
Background image of page 10
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
Background image of page 11

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

View Full DocumentRight Arrow Icon
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
Background image of page 12
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
Background image of page 13

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

View Full DocumentRight Arrow Icon
Introduction to Algorithms October 20, 2004 L14.14 © 2001–4 by Charles E. Leiserson Worst-case analysis Consider a sequence of n insertions. The
Background image of page 14
Image of page 15
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 Right Arrow Icon
Ask a homework question - tutors are online