Hash Tables

Projected Time

About 2 hours and 30 minutes

Prerequisites

Motivation

Hash tables are one of the most frequently used data structures. You’ll use them in your code a lot, so knowing how and when to use hash tables is important.

Knowing how hash tables work will give you a deeper understanding of why hash tables are used and what they’re good for. Hash tables are also often used in the solution to interview questions.

Uses of Hashing:

Objectives

Specific Things to Learn

Materials

Lesson

Common Mistakes / Misconceptions

Preamble

Languages call this type of data structure by many names:

Guided Practice

Let’s understand how to make hash maps using JavaScript.

Independent Practice

Coding questions that use hash tables

Implement a hash table

Basics: set(), get(), print() Challenge 1: Handle collisions with chaining Challenge 2: Make the table larger when enough items are added to the table

Challenge

Compare implementations of bucket collisions with a peer. Brainstorm different data structures one can use for implementing buckets. Code review others’ hash table implementations: Are clear parameter and method names used? Is the code DRY? Compare hashing algorithm choices with a peer.

Check for Understanding

Supplemental Materials