lecture14 - Introduction to Algorithms...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Introduction to Algorithms 6.046J/18.401J/SMA5503 Lecture 14 Prof. Charles E. Leiserson Introduction to Algorithms Day 24 L14.2 2001 by Charles E. Leiserson 2001 by Charles E. Leiserson How large should a hash table be? Problem: What if we dont know the proper size in advance? Goal: Make the table as small as possible, but large enough so that it wont 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 Day 24 L14.3 2001 by Charles E. Leiserson 2001 by Charles E. Leiserson Example of a dynamic table 1. I NSERT 1 2. I NSERT overflow Introduction to Algorithms Day 24 L14.4 2001 by Charles E. Leiserson 2001 by Charles E. Leiserson 1 1 Example of a dynamic table 1. I NSERT 2. I NSERT overflow Introduction to Algorithms Day 24 L14.5 2001 by Charles E. Leiserson 2001 by Charles E. Leiserson 1 1 2 Example of a dynamic table 1. I NSERT 2. I NSERT Introduction to Algorithms Day 24 L14.6 2001 by Charles E. Leiserson 2001 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 Day 24 L14.7 2001 by Charles E. Leiserson 2001 by Charles E. Leiserson Example of a dynamic table 1. I NSERT 2. I NSERT 3. I NSERT 2 1 overflow Introduction to Algorithms Day 24 L14.8 2001 by Charles E. Leiserson 2001 by Charles E. Leiserson Example of a dynamic table 1. I NSERT 2. I NSERT 3. I NSERT 2 1 Introduction to Algorithms Day 24 L14.9 2001 by Charles E. Leiserson 2001 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 Introduction to Algorithms Day 24 L14.10 2001 by Charles E. Leiserson 2001 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 Day 24 L14.11 2001 by Charles E. Leiserson 2001 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 Day 24 L14.12 2001 by Charles E. Leiserson 2001 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 Day 24 L14.13 2001 by Charles E. Leiserson 2001 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 Introduction to Algorithms Day 24 L14.14 2001 by Charles E. Leiserson 2001 by Charles E. Leiserson Worst-case analysis...
View Full Document

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

Page1 / 34

lecture14 - Introduction to Algorithms...

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