Dynamic-Table

Dynamic-Table - Introduction to Algorithms 6.046J/18.401J...

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

View Full Document Right Arrow Icon
October 31, 2005 Copyright © 2001-5 by Erik D. Demaine and Charles E. Leiserson L13.1 Prof. Charles E. Leiserson L ECTURE 13 Amortized Analysis Dynamic tables Aggregate method Accounting method Potential method Introduction to Algorithms 6.046J/18.401J
Background image of page 1

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

View Full DocumentRight Arrow Icon
October 31, 2005 Copyright © 2001-5 by Erik D. Demaine and Charles E. Leiserson L13.2 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
October 31, 2005 Copyright © 2001-5 by Erik D. Demaine and Charles E. Leiserson L13.3 Example of a dynamic table 1. I NSERT 1 1. 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
October 31, 2005 Copyright © 2001-5 by Erik D. Demaine and Charles E. Leiserson L13.4 1 Example of a dynamic table 1. I NSERT 1. I NSERT overflow
Background image of page 4
October 31, 2005 Copyright © 2001-5 by Erik D. Demaine and Charles E. Leiserson L13.5 1 2 Example of a dynamic table 1. I NSERT 1. 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
October 31, 2005 Copyright © 2001-5 by Erik D. Demaine and Charles E. Leiserson L13.6 Example of a dynamic table 1. I NSERT 1. I NSERT 1 2 1. I NSERT overflow
Background image of page 6
October 31, 2005 Copyright © 2001-5 by Erik D. Demaine and Charles E. Leiserson L13.7 Example of a dynamic table 1. I NSERT 1. I NSERT 1. 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
October 31, 2005 Copyright © 2001-5 by Erik D. Demaine and Charles E. Leiserson L13.8 Example of a dynamic table 1. I NSERT 1. I NSERT 1. I NSERT 2 1
Background image of page 8
October 31, 2005 Copyright © 2001-5 by Erik D. Demaine and Charles E. Leiserson L13.9 Example of a dynamic table 1. I NSERT 1. I NSERT 1. I NSERT 1. 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
October 31, 2005 Copyright © 2001-5 by Erik D. Demaine and Charles E. Leiserson L13.10 Example of a dynamic table 1. I NSERT 1. I NSERT 1. I NSERT 1. I NSERT 1. I NSERT 4 3 2 1 overflow
Background image of page 10
Image of page 11
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 33

Dynamic-Table - Introduction to Algorithms 6.046J/18.401J...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online