1 / 4

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

mahina
Download Presentation

Abstract Data Types (ADTs)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 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). Abstract Data Types (ADTs) Stacks

  2. Benefits of ADTs • encapsulation: less to worry about • division of labor • promotes code sharing • cheaper sub-contracts • facilitates unit-testing Stacks

  3. 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() List Abstract Data Type (ADT) Stacks

  4. 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 Position ADT Stacks

More Related