CSC148H1 Lecture Notes - Lecture 32: Hash Table, Functional Programming, Binary Search Algorithm

47 views6 pages
School
Course
Professor
CSC148: Lecture 32: Hashing and Exam Review
References: Pictures seen can be found on the CSC148 website:
http://www.teach.cs.toronto.edu/~csc148h/winter
Other Use Cases of Hashing
- Passwords stored as hashed values
- When you forget password, hard to retrieve even for admin
o Same hash value
Two different original passwords
- During log in, hash values are matched for given and store
- Odds are low for two passwords to have same hash value
- Hackers still follow brute force approach
Coding Hash Table
- Completed has table has expected performance in 𝛩(𝑛) for a dictionary with n entries
Unlock document

This preview shows pages 1-2 of the document.
Unlock all 6 pages and 3 million more documents.

Already have an account? Log in
- self.table = [[] for _in range(self.capacity)]
o Not self.table = [[]]* capacity
- old_table = self.table
o Temporarily save self.table
- self.items, self.collisions = 0, 0
o Reset items and collisions
- self.capacity *= 2
o Create double-sized table
- for bucket in old_table: …
o Insert old items into new table
Unlock document

This preview shows pages 1-2 of the document.
Unlock all 6 pages and 3 million more documents.

Already have an account? Log in
katrinasavvy and 38715 others unlocked
CSC148H1 Full Course Notes
1
CSC148H1 Full Course Notes
Verified Note
1 document

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers