抽象数据类型 定义了一组值和允许对其进行的操作,仅通过行为来描述 — 而不是通过代码。实现是实现该行为的具体结构(数组、链表、树)。
相同的 ADT,不同的实现
text
ADT "Queue": enqueue, dequeue, peek (FIFO contract)
Implementation A: array + two indices (ring buffer)
Implementation B: doubly linked list with head/tail pointers
Both honor the SAME contract; cost profiles differ.
为什么要分离它们
python
:
(): ...
(): ...
(): ...
