🎯 Objective: values + meaning + operations + a concrete implementation ➔ an ADT made concrete.
📦 Core Components:ADT (no impl) ➔ Data Type (ADT + impl) ➔ Data Structure (layout).
⚡ Key Constraint: the implementation a data type pins down fixes the operations’ complexity.
📝 Core
1. The Data Type (ADT + Implementation)
Definition ➔ values + meaning + operations + a concrete implementation (int, str, list).
Abstraction ladder ➔ ADT (no impl) → data type (ADT + impl) → Data Structure (layout, op = access).
Cost consequence ➔ the implementation is exactly what fixes the operations’ complexity.
2. Type Systems
Checking time ➔ static (compile-time, Java/C++) vs dynamic (run-time, Python).
Other axes ➔ strong vs weak coercion | primitive (int) vs composite (list) | value (copied) vs reference (shared) semantics.
Type safety ➔ prevents applying an operation to an incompatible value.
⚙️ Core Implementation
🔹 Values, operations, implementation
data types in Python
x: int = 7 # values (…-1,0,1…), meaning (integers), ops (+,//,<), bit-level imply = x // 2 # the operation's result depends on the implementations: str = "abcd" # a different data type with its own values/ops/impl
💡 Common Mistake:Value vs reference semantics ➔ value copies on assignment (mutation can’t affect the original); reference shares the object (mutation affects all names) — the classic Python-mutable-aliasing bug.
When It Flips: complexity follows implementation — the same ADT realised as different data types has different costs (the implementation is what a data type adds). Static-vs-dynamic trade-off: early error detection + optimisation vs flexibility + development speed.
📊 Exam Execution Trace
Manual Execution Trace
Placing list on the abstraction ladder:
Step / State
Role
Answer for list
0 (Init)
—
—
1
ADT
”ordered sequence with index access” (interface)
2
Data Type
list — interface + dynamic-array storage + complexities