Presentation is loading. Please wait.

Presentation is loading. Please wait.

© 2004 Goodrich, Tamassia Stacks1 Abstract Data Types (ADTs) An abstract data type (ADT) is a contract between the user of a data structure and its implementor.

Similar presentations


Presentation on theme: "© 2004 Goodrich, Tamassia Stacks1 Abstract Data Types (ADTs) An abstract data type (ADT) is a contract between the user of a data structure and its implementor."— Presentation transcript:

1 © 2004 Goodrich, Tamassia Stacks1 Abstract Data Types (ADTs) An abstract data type (ADT) is a contract between the user of a data structure and its implementor. An ADT specifies: type of data stored (e.g. any objects, or only ints) available methods, with parameter and return types error conditions associated with methods (optionally) performance guarantees, in terms of space and/or time Can be very simple (list) or very complex (stock exchange).

2 © 2004 Goodrich, Tamassia Stacks2 Benefits of ADTs encapsulation: less to worry about division of labor promotes code sharing cheaper sub-contracts facilitates unit-testing

3 © 2004 Goodrich, Tamassia Stacks3 List Abstract Data Type (ADT) The List ADT models a sequence of positions storing arbitrary objects It establishes a before/after relation between positions Can be implemented in various ways: array singly-linked doubly-linked Accessor methods: first(), last() prev(p), next(p) Update methods: replace(p, e) insertBefore(p, e), insertAfter(p, e), insertFirst(e), insertLast(e) remove(p) convenience methods: isEmpty()

4 © 2004 Goodrich, Tamassia Stacks4 Position ADT The Position ADT models the notion of place within a data structure where a single object is stored It gives a unified view of diverse ways of storing data, such as a cell of an array a node of a linked list Just one method: object element(p): returns the element stored at position p


Download ppt "© 2004 Goodrich, Tamassia Stacks1 Abstract Data Types (ADTs) An abstract data type (ADT) is a contract between the user of a data structure and its implementor."

Similar presentations


Ads by Google