Questions: List Abstract Data Type: Interface and Semantics

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

You're building a text editor that inserts characters at the cursor position frequently (near the beginning of large documents) and rarely reads by index. Which List ADT implementation should you choose?

AArray-backed list, because O(1) random access makes cursor positioning fast
BLinked-list-backed list, because front insertions are O(1) rather than O(n)
CEither implementation — they both support insert(), so performance is identical
DArray-backed list, because contiguous memory is always faster
Question 2 Multiple Choice

A software library exports a List interface with get(), insert(), remove(), and size(). What does the ADT guarantee to code that uses it?

AThe implementation uses an array internally for maximum performance
BAll operations run in O(1) time
CThe operations behave as specified regardless of the internal implementation
DThe implementation can be swapped without recompiling client code
Question 3 True / False

Two classes both implement a List ADT. Since they support the same operations, a program using either one will behave identically regardless of which is chosen.

TTrue
FFalse
Question 4 True / False

The power of the ADT abstraction is that it lets you switch implementations without changing the code that uses the data structure.

TTrue
FFalse
Question 5 Short Answer

Why is it useful to think in terms of ADTs even when you already know which implementation you'll use?

Think about your answer, then reveal below.