Computer Science I / Abstract Data Types and Interfaces
Practice question · Select all that apply

A program uses a List ADT. Its array implementation is replaced by a linked one, and every published operation still behaves as documented. Select every statement that remains true afterwards.

Hints
  1. The swap changes the implementation and nothing about the interface.
  2. One option would mean the two structures were not implementations of the same ADT at all.
Show the answer
  • A. get, add, remove and size behave as before
  • B. get(i) may take substantially longer
  • C. Code assuming contiguous storage may break
  • E. The memory layout of the elements has changed
Why

Behaviour is preserved but performance and layout are not, that is the entire trade being made. The one false statement is that the operations mean something different: if they did, the swap would not be legal. Code that reached past the interface to assume contiguity was never protected, and it is exactly such code that breaks.

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