Heaps of Hashing (Discussion 9) (Heap, bảng băm và mã băm) - Christine Zhou
Génération de l'aperçu...
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.
Description
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
Résumé IA
- Nom du document
- Heaps of Hashing (Discussion 9) (Heap, bảng băm và mã băm) - Christine Zhou
- École / Cours
- University of California, Berkeley · Lập trình Java
- Contenu
- 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.
- Table des matières
- Ce document n'a pas de table des matières claire.
- Pages
- 13 pages
- Téléversé par
- Uni24h
Foire aux questions
Ce document est-il gratuit ?
Oui. « Heaps of Hashing (Discussion 9) (Heap, bảng băm và mã băm) - Christine Zhou » est gratuit — il suffit de vous connecter et de cliquer sur Télécharger pour obtenir le fichier original.
Combien de pages compte ce document ?
Le document contient 13 pages, pour le cours Lập trình Java. Vous pouvez le prévisualiser en ligne avant de le télécharger.
Puis-je prévisualiser avant de télécharger ?
Oui. Vous pouvez prévisualiser ce document directement sur cette page avec le lecteur en ligne, puis décider de le télécharger ou non.
Heaps of Hashing (Discussion 9) (Heap, bảng băm và mã băm) - Christine Zhou
Génération de l'aperçu...
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
Lire le document entier
- Nom du document
- Heaps of Hashing (Discussion 9) (Heap, bảng băm và mã băm) - Christine Zhou
- École / Cours
- University of California, Berkeley · Lập trình Java
- Contenu
- 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.
- Table des matières
- Ce document n'a pas de table des matières claire.
- Pages
- 13 pages
- Téléversé par
- Uni24h
Commentaires (0)
Aucun commentaire pour le moment. Soyez le premier !
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
Commentaires (0)
Aucun commentaire pour le moment. Soyez le premier !