From the course: Advanced Algorithmic Thinking with Python
Unlock this course with a free trial
Join today to access over 25,500 courses taught by industry experts.
Python code for hash tables - Python Tutorial
From the course: Advanced Algorithmic Thinking with Python
Python code for hash tables
[Instructor]- On Branch 0502, you'll find a file called hash table linear probing.py. Now this is just to give you some idea of how you might go about implementing a linear probing style hashtable yourself, obviously in the real world this would be done in a much more sophisticated way but here we're just learning about the concept and it's quite useful to have some actual code to look at. So if you like have a little play with this code. On line one we have a constant defining our table size you can change that, you can add or remove contacts and we have my hash function and you might want to try a different hash function. And then we have an insert function and a lookup. And then on line 44 we're creating an empty hash table to begin with that's as many entries of none as the size of the table. And then we add our contacts from our list on lines 47 through 51 and print our list. And then we're doing some look up at the…