Skip to content
Tech Interview Prep home
Technical interview guide

Core Data Structures

Lists, tuples, dicts, and sets — their underlying implementations and when each is the right choice.

Read
48 min
Practice MCQs
25
Interview QA
25
Edition
v2
Editorial status
Reviewed

Scope: Python 3.14; notes distinguish language guarantees from CPython implementation behavior.

Interview QA

Treat each question like a live interview question: answer out loud first (structure, assumptions, tradeoffs), then open the model answer to spot gaps and rehearse a tighter follow-up.

Curated: · Written: · Reviewed:

QA-1

Compare list and deque costs for stacks, queues, and random access.

QA-2

Explain aliasing versus copying for nested Python lists and how you would define ownership.

QA-3

When would you choose `sort()` over `sorted()`, and how does stability affect the design?

QA-4

What does tuple immutability guarantee, and what does it not guarantee?

QA-5

How do Python dictionaries and sets handle hash collisions, and what triggers table resizing?

QA-6

How does membership testing time complexity differ across standard lists, sets, and sorted lists maintained via bisect?

QA-7

Explain how hashing and equality cooperate during dictionary lookup.

QA-8

What invariants must a production dictionary key satisfy?

QA-9

Describe Python's dictionary insertion-order contract, including update and reinsertion.

QA-10

When is a dictionary view useful, and when must it be materialized?

QA-11

Compare subscription, `get`, `setdefault`, and `defaultdict` for missing keys.

QA-12

How would you layer configuration mappings while detecting forbidden collisions?

QA-13

What guarantees should an API avoid making about set iteration?

QA-14

Use set algebra to explain difference versus symmetric difference in a real review.

QA-15

When is `frozenset` a better value model than tuple or set?

QA-16

How do you reason about average and worst-case membership cost?

QA-17

Contrast shallow copy, deep copy, and deliberate reconstruction of an object graph.

QA-18

Diagnose the repeated-row aliasing bug created by sequence multiplication.

QA-19

Why are mutable default arguments persistent, and when might that persistence be intentional?

QA-20

How do truthiness checks differ from sentinel checks in API design?

QA-21

Explain the comparison semantics of sequences and sets without claiming a total order.

QA-22

Defend a container choice for a high-throughput FIFO queue.

QA-23

What `Counter` behaviors around zero and negative counts matter in production?

QA-24

How would you model ordered uniqueness without relying on set internals?

QA-25

Present a repeatable method for selecting a Python container from workload requirements.