Computer Science I / Abstract Data Types and Interfaces
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
  1. Every test passes and every answer is right. Ask what changed that no test measured.
  2. 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.

Read the lesson: Abstract Data Types and Interfaces →

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