中国高校课件下载中心 》 教学资源 》 大学文库

《算法入门》(英文版)Lecture 14 Prof. Charles E. Leiserson

文档信息
资源类别:文库
文档格式:PDF
文档页数:34
文件大小:198.39KB
团购合买:点击进入团购
内容简介
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).
刷新页面文档预览

Introduction to algorithms 6.046J/18,401J/SMA5503 Lecture 14 Prof charles e. leiserson

Introduction to Algorithms 6.046J/18.401J/SMA5503 Lecture 14 Prof. Charles E. Leiserson

How large should a hash table be? Goal: Make the table as small as possible but large enough so that it wont overflow(or otherwise become inefficient Problem: what if we don 't know the proper size In advance ? Solution: Dynamic tables IDEA: 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 c 2001 by Charles E Leiserson Introduction to Agorithms Day 24 L14.2

© 2001 by Charles E. Leiserson Introduction to Algorithms Day 24 L14.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). IDEA: 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

Example of a dynamic table 1.Ⅰ NSErT 2.Ⅰ NSERT overflow c 2001 by Charles E Leiserson Introduction to Agorithms Day 24 L14.3

© 2001 by Charles E. Leiserson Introduction to Algorithms Day 24 L14.3 Example of a dynamic table 1. INSERT 1 2. INSERT overflow

Example of a dynamic table 1.Ⅰ NSErT 2.Ⅰ NSERT overflow c 2001 by Charles E Leiserson Introduction to Agorithms Day 24 L14.4

© 2001 by Charles E. Leiserson Introduction to Algorithms Day 24 L14.4 11 Example of a dynamic table 1. INSERT 2. INSERT overflow

Example of a dynamic table 1.Ⅰ NSErT 2.Ⅰ NSERT 2 c 2001 by Charles E Leiserson Introduction to Agorithms Day 24 L14.5

© 2001 by Charles E. Leiserson Introduction to Algorithms Day 24 L14.5 11 2 Example of a dynamic table 1. INSERT 2. INSERT

Example of a dynamic table 1 INSERT 2.Ⅰ NSERT 2 3. INSERT overflow c 2001 by Charles E Leiserson Introduction to Agorithms Day 24 L14.6

© 2001 by Charles E. Leiserson Introduction to Algorithms Day 24 L14.6 Example of a dynamic table 1. INSERT 2. INSERT 11 22 3. INSERT overflow

Example of a dynamic table 1 INSERT 2.Ⅰ NSERT 2 3. INSERT overflow c 2001 by Charles E Leiserson Introduction to Agorithms Day24L14.7

© 2001 by Charles E. Leiserson Introduction to Algorithms Day 24 L14.7 Example of a dynamic table 1. INSERT 2. INSERT 3. INSERT 2 1 overflow

Example of a dynamic table 1 INSERT 2.Ⅰ NSERT 2 3. INSERT c 2001 by Charles E Leiserson Introduction to Agorithms Day 24 L14.8

© 2001 by Charles E. Leiserson Introduction to Algorithms Day 24 L14.8 Example of a dynamic table 1. INSERT 2. INSERT 3. INSERT 2 1

Example of a dynamic table 1 INSERT 2.Ⅰ NSERT 3. INSERT 234 4. INSERT c 2001 by Charles E Leiserson Introduction to Agorithms Day 24 L14.9

© 2001 by Charles E. Leiserson Introduction to Algorithms Day 24 L14.9 Example of a dynamic table 1. INSERT 2. INSERT 3. INSERT 4. INSERT 4 3 2 1

Example of a dynamic table 1 INSERT 2.Ⅰ NSERT 3. INSERT 234 4. INSERT 5 INSERT overflow c 2001 by Charles E Leiserson Introduction to Agorithms Day24L14.10

© 2001 by Charles E. Leiserson Introduction to Algorithms Day 24 L14.10 Example of a dynamic table 1. INSERT 2. INSERT 3. INSERT 4. INSERT 5. INSERT 4 3 2 1 overflow

刷新页面下载完整文档
VIP每日下载上限内不扣除下载券和下载次数;
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
相关文档