Computer Science I / Abstract Data Use
Practice question · True or false

Because an ADT's interface says nothing about cost, two correct implementations of the same interface can differ enormously in performance.

Hints
  1. The interface names operations; it does not price them.
  2. A list and a hash table can both offer contains.
Show the answer

True

Why

True. contains is O(n) on a list and O(1) on a hash table, and both satisfy the same interface. That is the point and the danger of an ADT: it lets you swap implementations freely, and it lets you swap in one whose costs make every caller quadratic without changing a line of them.

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