Discover how to use a high-level implementation of hash tables with dictionaries in Python. Learn how to write code that maps keys to values in order to take advantage of the hash table data structure in your programs.
- [Instructor] So how do we actually use…these hash based data structures in code?…Well let's take a look at an example in Python 3.…In Python, we get dictionaries,…which are essentially a collection of key value pairs,…and in our case, our hash based data structure of choice.…Internally, however, it's stored as an array,…whose indices are obtained…using a hash function on the keys.…Jumping into Python 3, we can code up an example…where we access the capital of a state…by using the name of the state.…
This means the name of the state would be the key,…and the capital of the state would be…its corresponding value.…To create a dictionary, we simply name the dictionary,…in this case, we'll name it statesToCapitals,…and use a open and closing curly bracket…to initialize and create this dictionary.…Here, it's empty.…The next step is to add a few key value pairs.…To do that, we access the name of the dictionary,…statesToCapitals, and then decide what key…we want to use for this key value pair.…
Here, we'll use Texas, that's the state we're going to add.…
- Data types: Booleans, numbers, strings, and more
- Multidimensional arrays
- Jagged arrays
- Search and sort arrays
- Linked lists
- Stacks and queues
- Hash functions and hash tables
- Trees and graphs
Skill Level Intermediate
Understand data structures1m 25s
1. Introduction to Data Structures
4. Stacks and Queues
5. Hash-Based Data Structures
6. Trees and Graphs
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.