CSC148H1 Lecture Notes - Lecture 31: Birthday Problem, Hash Table

52 views4 pages
School
Course
Professor
CSC148: Lecture 31: Chaining or Probing
References: The pictures can be found on the CSC148 website:
http://www.teach.cs.toronto.edu/~csc148h/winter
Chaining or Probing
- Couple of tactics for dealing with 2 different keys ending up at same index
o Chaining- keep a small list at that index (sometimes called bucket)
o Probing- explore, in a systematic way, until the next open index
- Either tactic has costs
- Keep collisions to a minimum by keeping the list partly empty
- Python dictionaries are implemented using has tables and probing
- The cost of collisions is kept small by enlarging the underlying list when necessary
o Cost of enlarging is amortized over many dictionary accesses
- Result = access to a dictionary element is 𝛩(1)
o The time it takes to access a list element
- 1 downside:
o Extra work required to order the keys or values
o What is their “natural” order?
Collisions: Linear Probing
Unlock document

This preview shows page 1 of the document.
Unlock all 4 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

Related Documents