Computer Science I / Abstract Data Use
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
  1. Ask what a caller must know before writing a loop that calls something a million times.
  2. 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.

Read the lesson: Abstract Data Use →

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