WK 6 Hashing + Map

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/14

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 10:25 PM on 4/22/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

15 Terms

1
New cards

What is the internal structure of a HashSet?

An array of buckets containing lists of hashes

2
New cards

How does the HashSet add() method work? (4 steps)

Calls hashCode() on the value, calculate bucket index, check for duplicates, if none then add

3
New cards

HashSets can have duplicate values (t/f)

False

4
New cards

In hashSets, how do you calculate bucket index?

hash%arrayLength

5
New cards

What is the internal structure of hashMap?

An array of buckets where each bucket stores key-value pairs, where only the key is hashed

6
New cards

In a hashMap, which part of the key-value pair gets hashed?

key

7
New cards

If a.equals(b) is true, then a.hashCode() == b.hashCode() must also be true. (t/f)

true

8
New cards

Hashing transforms ___ search into ___ lookup (Big-O notation)

O(n), O(1)

9
New cards

Hashset stores ___________, while hashmap stores ___________

unique values, key-value pairs

10
New cards

How do hashsets/hashmaps handle collisions?

Chaining

11
New cards

Every java object has a hashCode() method which returns a ____________ which represents it.

32-bit integer

12
New cards

Custom objects need to override hashCode() if they override equals(), otherwise they will break in hashsets/hashmaps (t/f)

true

13
New cards

Hashset/hashmap has O(1) time complexity for most common functions, but it doesn’t have ________, _________, and doesn’t allow ___________.

order, index, duplicates

14
New cards

After adding objects to the hashset/hashmap you can still modify them. (t/f)

false

15
New cards

What is a real-world example of hashing methods?

Libraries, phonebooks