Practice question · Multiple choice
A library documents a function's behaviour but not its complexity. Callers then write loops assuming it is cheap. Whose mistake is it?
Hints
- Ask what a caller must know before writing a loop that calls something a million times.
- C++ and Java document container complexity. Why would they bother if it were an implementation detail?
Show the answer
D. Shared, the caller assumed a guarantee the library never documented
Why
Behaviour alone does not let a caller design; they plan around cost, so the omission guarantees the assumption. Real libraries promote complexity into the contract for that reason, and pay for it by constraining future implementations, which is a deliberate trade rather than an oversight.
Practise Abstract Data Use
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 Use
- A stack ADT implemented with a fixed-size array can overflow when pushed too many times; the same ADT over a…
- A team replaces a stack's array implementation with a linked-node one. The published operations behave…
- Order what happens when an object is created and then used.
- Because an ADT's interface says nothing about cost, two correct implementations of the same interface can…
- A stack ADT is being documented. Sort each statement by whether it belongs in the published interface or is…