13-Amortized-Analysis

# 13-Amortized-Analysis - Algorithms LECTURE 13 Amortized...

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

Algorithms L13.1 Professor Ashok Subramanian L ECTURE 13 Amortized Analysis Dynamic tables Aggregate method Accounting method Potential method Algorithms

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

View Full Document
Algorithms 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.
Algorithms L13.3 Example of a dynamic table 1. I NSERT 1 1. I NSERT overflow

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

View Full Document
Algorithms L13.4 1 Example of a dynamic table 1. I NSERT 1. I NSERT overflow
Algorithms L13.5 1 2 Example of a dynamic table 1. I NSERT 1. I NSERT

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

View Full Document
Algorithms L13.6 Example of a dynamic table 1. I NSERT 1. I NSERT 1 2 1. I NSERT overflow
Algorithms L13.7 Example of a dynamic table 1. I NSERT 1. I NSERT 1. I NSERT 2 1 overflow

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

View Full Document
Algorithms L13.8 Example of a dynamic table 1. I NSERT 1. I NSERT 1. I NSERT 2 1
Algorithms L13.9 Example of a dynamic table 1. I NSERT 1. I NSERT 1. I NSERT 1. I NSERT 4 3 2 1

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

View Full Document
Algorithms 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
Algorithms L13.11 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

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

View Full Document
Algorithms L13.12 Example of a dynamic table 1. I NSERT 1. I NSERT 1. I NSERT 1. I NSERT 1. I NSERT 4 3 2 1
Algorithms L13.13 Example of a dynamic table 1. I NSERT 1. I NSERT 1. I NSERT 1. I NSERT 1. I NSERT 6 1. I NSERT 5 4 3 2 1 7 1. I NSERT

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

View Full Document
L13.14 Worst-case analysis Consider a sequence of n insertions. The worst-case time to execute one insertion is Θ ( n ) . Therefore, the worst-case time for n insertions is n · Θ ( n ) = Θ ( n ) . WRONG!
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 42

13-Amortized-Analysis - Algorithms LECTURE 13 Amortized...

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

View Full Document
Ask a homework question - tutors are online