Definition: A set of data values & related operations that are accurately specified independent of any particular implementation.
As the data values and operations are described with mathematical precision, instead of as an implementation in a computer language, we might reason about effects of the operations, relationship to other abstract data types, whether a programming language implements the particular data type, etc.
Regard the given abstract data type:
Structure data tree
type Tree = nil | fork (Element , Tree , Tree)
Operations:
null : Tree -> Boolean leaf : Tree -> Boolean
fork : (Element , Tree , Tree) -> Tree
left : Tree -> Tree // It illustrated the properties of tree that left of a tree is also a tree.
right: Tree -> Tree contents: Tree -> Element height (nil) = 0 |
height (fork(e,T,T')) = 1+max(height(T), height(T'))
weight (nil) = 0 |
weight (fork(e,T,T')) = 1+weight(T)+weight(T')
Figure: A binary tree