An ADT that contains a collection of items (normally primitive data types), each being identified by an index, however, unlike arrays, it is flexible and can change its length.

Properties

  • mutable length
    • if no more space is present, we can increment the length
    • this is why elements can be inserted
  • items are accessed using 0-based indexing
  • elements are ordered

Signature

name: List
import: element, integer, bool
operators:
  newList: -> List;
  prepend: List × element -> List;
  append: List × element -> List;
  insert: List × element × integer -> List;
  get: List × integer -> List;
  delete: List × integer -> List;
  length: List -> integer;
  isEmpty: List -> boolean;

Note that the ability to set, get can be added, however the ultimate goal is to highlight list’s unique capability of resizable lengths, hence the emphasis on “append”, “prepend”, “insert” operators.

Implementation