Free Online Flashcard Deck

06 Hash Tables Free Online FlashCards

Study 06 Hash Tables with 12 free online flashcards. Review key terms, definitions, and concepts with this interactive flashcard deck.

12 cards
01
Front

What is a hash table?

Back

A hash table is a data structure that stores key–value pairs and supports efficient insertion, lookup, and deletion.

02
Front

What properties should a useful hash function have?

Back

A useful hash function is deterministic, fast, well distributed, and consistent with equality.

03
Front

What is a collision in a hash table?

Back

A collision occurs when two different keys map to the same table index.

04
Front

How does separate chaining resolve collisions?

Back

Separate chaining stores all entries with the same index in a collection associated with that slot, often a linked list.

05
Front

How does open addressing resolve collisions?

Back

Open addressing stores every entry directly in the table array and searches alternative slots using a probe sequence.

06
Front

Why does open addressing use tombstones?

Back

A tombstone marks a deleted slot so probing continues through it instead of incorrectly ending a search.

07
Front

Why must entries be rehashed after resizing?

Back

Resizing requires recomputing indexes because changing the capacity changes the modulus used to place entries.

08
Front

What must a hash function guarantee about equal keys?

Back

Equal keys must produce the same hash value. Otherwise, a lookup may search a different location from the one used during insertion.

09
Front

How does data-structure hashing differ from cryptographic hashing?

Back

Data-structure hashing prioritizes speed and good distribution. Cryptographic hashing additionally aims to resist intentional attacks and make inputs difficult to recover or manipulate.

10
Front

What is primary clustering in linear probing?

Back

Primary clustering is the formation of long runs of consecutive occupied slots. In linear probing, these runs increase the probe lengths of later operations.

11
Front

How does double hashing determine probe positions?

Back

Double hashing uses a second hash function to determine the probe step: pi(k)=(h1(k)+i h2(k)) mod mp_i(k)=(h_1(k)+i\,h_2(k))\bmod m.

12
Front

When are hash-table operations expected to take O(1)O(1) time?

Back

Expected O(1)O(1) operations require assumptions such as good distribution, controlled load factor, and an effective collision strategy. Worst-case search, insertion, or deletion can still take O(n)O(n).