Data Type

Context: FIT1008_MOC · an Abstract Data Type (ADT) plus an implementation · the middle rung of the abstraction ladder · contrast Data Structure

Quick Revision

  • 🎯 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 timestatic (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

⚖️ Core Decision Matrix

ConceptValues + meaningOperationsImplementation
Abstract Data Type (ADT)
Data Type
Data Structurevalues onlyaccess only✅ (layout)

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 / StateRoleAnswer for list
0 (Init)
1ADT”ordered sequence with index access” (interface)
2Data Typelist — interface + dynamic-array storage + complexities
3Data Structurethe resizable Array (Data Structure) underneath

Applied Exercise

Problem: Enumerate the type-system axes that classify a data type. Derivation Proof / Hand-Calculation Walkthrough:

Final Extracted Output: a data type is positioned by checking-time, coercion strength, and assignment semantics.

🧠 Active Recall