AI Hints
Home›DSA in Python Tutorial›Anagrams and Review
DSA in Python · Lesson 30 of 132

Hashing Quiz

Test yourself.

⏱ 2 min read▶ Video at 34:14🎓 Free
Watch this lesson in the DSA in Python courseWatch on YouTube ↗Full DSA in Python course

Hash tables are the most useful tool in this course so far. Let's make sure you're comfortable with them. Pause, answer, then listen.

Hashing Quiz
From the video: Hashing Quiz
  • The most useful tool
  • Check yourself
  • Pause, answer, listen

Question 1

What's the average cost of checking whether an item is in a set? The answer is O of one. Sets are hash tables, so they jump straight to the right bucket.

Quick check
x in my_set, on average, is…

Question 2

Which of these can't be a dictionary key? A string, a tuple, or a list? The answer is a list. Keys must never change, and lists can change.

Quick check
Which can't be a dict key?

Question 3

In two sum, what does the dictionary store? The answer is each number we've seen, and its position. Then we can find a partner in O of one.

Quick check
In two sum, the dict stores…

Question 4

Which technique finds the longest substring without repeats? The answer is a sliding window, which grows and shrinks as we scan.

Quick check
Longest substring without repeats uses…

Summary

Brilliant. Next, a new section. Stacks, queues, and linked lists, the structures that keep things in order.

Key takeaways
  • Sets: O(1) membership
  • Keys must not change
  • Windows for substrings
Next up: Stacks — last in, first out