table of contents

abstract data type

2024-02-01

abstract data types, commonly abbreviated *ADT*s, are a way of classifying data structures based on how they are used and the behaviors they provide. they do not specify how the data structure must be implemented or laid out in memory, but simply provide a minimal expected interface and set of behaviors. for example, a stack is an abstract data type that specifies a linear data structure with LIFO behavior. stacks are commonly implemented using arrays or linked lists, but a needlessly complicated implementation using a binary search tree is still a valid implementation. to be clear, it is incorrect to say that stacks are arrays or vice versa. an array can be used as a stack. likewise, a stack can be implemented using an array.

since abstract data types dont specify an implementation, this means its also incorrect to talk about the time complexity of a given abstract data type. an associative array may or may not have average search times. An associative array that is implemented by a hash table does have average search times.

to further complicate matters, since certain abstract data types are almost always implemented with a particular data structure, some programmers will use the two terms interchangeably: for example, priority queue and heap, or associative array and hash table. the context in which the term is being used can usually provide distinction.