Practice question · Multiple choice
A team swaps a List implementation from array-backed to linked, changes no calling code, and the nightly batch job takes six hours instead of twenty minutes. Every test passes. What did the interface fail to promise?
Hints
- Every test passes and every answer is right. Ask what changed that no test measured.
list[500]in an array is one memory read. What is it in a chain of nodes?
Show the answer
B. Cost, which the ADT's contract never mentioned
Why
The contract covered behaviour and said nothing about cost, so indexing went from one address computation to walking five hundred pointers, correct every time, and catastrophically slower. It is why real libraries publish complexity as part of the interface, accepting the constraint that creates.
Practise Abstract Data Types and Interfaces
The app has 6 more questions on this lesson, and keeps your place in the course. Computer Science I is free to start.
More questions on Abstract Data Types and Interfaces
- A List ADT is being documented. Sort each statement by whether it belongs to the interface or describes one…
- A program uses a List ADT backed by an array. The implementation is swapped for a linked one and not a single…
- A program uses a List ADT. Its array implementation is replaced by a linked one, and every published…
- Documenting a List ADT by writing down the array implementation's exact timings makes the documentation more…