Heaps of Hashing (Discussion 9) (Heap, bảng băm và mã băm) - Christine Zhou
正在生成预览...
Tài liệu thảo luận về heap, bảng băm và mã băm trong môn học cấu trúc dữ liệu, kèm theo bài tập và thông báo.
描述
Discussion 9: Heaps of Hashing Christine Zhou Agenda Announcements Heaps Problem 1 Hash tables Problem 2 Hash Codes Problem 3 Announcements Mid-semester survey due this Friday Less time to work on the problems by yourself Goes a little too slowly Don’t really need to talk to each other to discuss the problem Make sure to go through the harder problems Midterm coming up next week Start studying early! Advising sessions are updated weekly! tinyurl.com/cs61b-advising Project 2 Take a look at spec for extra credit opportunities! Start early! We’ll have extra office hours just like we did for Proj1 Refetch from shared to get an updated col/row Heaps Sometimes we want to prioritize elements in a certain way, always get the minimum Use a heap! Complete: missing items only at the bottom level and pushed as far left on the bottom level as possible (Min/Max) heap property: every node’s value is (less/greater) than or equal to its children’s value Common Methods of Heaps Insert Put new item in first free bottom leftmost position, then bubble up removeMin/removeMax Replace root item with the bottom rightmost item, then bubble down the root getMin/getMax Return the value at the root How do we represent heaps? 1 Heaps of fun 1 Heaps of fun HashMaps Use an array to represent your data For each key-value pair, assign each key a “hash code” mod (%) the hash code by the length of the array (this gives you a number between 0 and array.length - 1), use this as the index! N = num elements, M = num buckets, C = some constant If N/M > C, then increase M! N/M is called the load factor If we have multiple elements that go to same place in the array, usually we will keep track of a list Be careful about negative numbers when modding! This is called external chaining What is the runtime of .contains and .insert? 2 HashMap Modification Hash Codes What is necessary for a valid hash code? If A.equals(B) is
AI 摘要
- 文档名称
- Heaps of Hashing (Discussion 9) (Heap, bảng băm và mã băm) - Christine Zhou
- 学校 / 课程
- University of California, Berkeley · Lập trình Java
- 内容
- Tài liệu thảo luận về heap, bảng băm và mã băm trong môn học cấu trúc dữ liệu, kèm theo bài tập và thông báo.
- 目录
- 此文档没有清晰的目录。
- 页数
- 13 页
- 上传者
- Uni24h
常见问题
此文档免费吗?
是的。“Heaps of Hashing (Discussion 9) (Heap, bảng băm và mã băm) - Christine Zhou”是免费的 — 只需登录并点击“下载”即可获取原始文件。
这份文档有多少页?
该文档共有 13 页,适用于课程 Lập trình Java。您可以在下载前进行在线预览。
我可以在下载前预览吗?
是的。您可以通过在线阅读器直接在本页面预览此文档,然后再决定是否下载。
Heaps of Hashing (Discussion 9) (Heap, bảng băm và mã băm) - Christine Zhou
正在生成预览...
Discussion 9: Heaps of Hashing Christine Zhou Agenda Announcements Heaps Problem 1 Hash tables Problem 2 Hash Codes Problem 3 Announcements Mid-semester survey due this Friday Less time to work on the problems by yourself Goes a little too slowly Don’t really need to talk to each other to discuss the problem Make sure to go through the harder problems Midterm coming up next week Start studying early! Advising sessions are updated weekly! tinyurl.com/cs61b-advising Project 2 Take a look at spec for extra credit opportunities! Start early! We’ll have extra office hours just like we did for Proj1 Refetch from shared to get an updated col/row Heaps Sometimes we want to prioritize elements in a certain way, always get the minimum Use a heap! Complete: missing items only at the bottom level and pushed as far left on the bottom level as possible (Min/Max) heap property: every node’s value is (less/greater) than or equal to its children’s value Common Methods of Heaps Insert Put new item in first free bottom leftmost position, then bubble up removeMin/removeMax Replace root item with the bottom rightmost item, then bubble down the root getMin/getMax Return the value at the root How do we represent heaps? 1 Heaps of fun 1 Heaps of fun HashMaps Use an array to represent your data For each key-value pair, assign each key a “hash code” mod (%) the hash code by the length of the array (this gives you a number between 0 and array.length - 1), use this as the index! N = num elements, M = num buckets, C = some constant If N/M > C, then increase M! N/M is called the load factor If we have multiple elements that go to same place in the array, usually we will keep track of a list Be careful about negative numbers when modding! This is called external chaining What is the runtime of .contains and .insert? 2 HashMap Modification Hash Codes What is necessary for a valid hash code? If A.equals(B) is
阅读全文
- 文档名称
- Heaps of Hashing (Discussion 9) (Heap, bảng băm và mã băm) - Christine Zhou
- 学校 / 课程
- University of California, Berkeley · Lập trình Java
- 内容
- Tài liệu thảo luận về heap, bảng băm và mã băm trong môn học cấu trúc dữ liệu, kèm theo bài tập và thông báo.
- 目录
- 此文档没有清晰的目录。
- 页数
- 13 页
- 上传者
- Uni24h
评论 (0)
暂无评论。快来抢沙发吧!
Misc.onclusion (Discussion 14-END) (Ôn tập cấu trúc dữ liệu) - Christine Zhou
Final Review Solutions (Cấu trúc dữ liệu heap, hàng đợi ưu tiên và duyệt đồ thị) - Ching and Christines
Giáo trình Lập trình Java
Inheritance (Discussion 4) (Kế thừa trong Java) - Christine Zhou
Asymptotic Analysis (Discussion 7) (Phân tích tiệm cận) - Christine Zhou
Chương 7.Cơ học lượng tử - Vật lý đại cương 3 - TS.Nguyễn Thị Trang
Chương 6.Quang học lượng tử - Vật lý đại cương 3 - TS.Nguyễn Thị Trang
Chương 5.Thuyết tương đối - Vật lý đại cương 3 - TS.Nguyễn Thị Trang
Chương 4. Tán xạ ánh sáng - Vật lý đại cương 3 - TS.Nguyễn Thị Trang
Chương 3.Phân cực ánh sáng - Vật lý đại cương 3 - TS.Nguyễn Thị Trang
评论 (0)
暂无评论。快来抢沙发吧!