29A. Abstract Data Types


A motivating example

You have seen the Equivalence Manager. It has a conceptual part, consisting of

  1. a type, Equiv,

  2. a concept of what an Equiv object stands for, and

  3. an interface telling just which functions (including merge and equivalent) are provided.

There is also an implementation, consisting of

  1. a way of representing a thing of type Equiv (as an array of bosses), and

  2. definitions of the functions in the interface, plus a definition of a function, leader, that is not part of the interface.

Assignment 5 has you used type Equiv for finding a minimal spanning tree of a graph.


Abstract data types

The conceptual part of the equivalence manager is an example of an abstract data type (ADT). In general, an ADT has the following parts.

  1. There is a type. Let's call it T.

  2. There is a conceptual idea of what objects of type T are.

  3. There is an interface that lists functions and constants that are available for type T and says what those functions and constants mean in conceptual terms.

An ADT implementation is a way of providing the ADT in software. It has the following parts.

  1. There is a representation of objects of type T that tells how those objects are stored in the memory.

  2. There are algorithms (function definitions) for carrying out the functions in the interface. The algorithms usually depend heavily on the data representation.

With this page, we begin to look at (1) an ADT list of integers, (2) an implementation of lists of integers, and (3) ideas for developing algorithms involving lists of integers that are built on top of the ADT.