
Page 1
1
http://www.cse.unl.edu/~goddard/Courses/CSCE310J
Abstract Data Types
and Basic Data Structures
Dr. Steve Goddard
CSCE 310J: Data Structu res & Algorithms
2
IGiving credit where credit is due:
•Most of slides for this lecture are based on slides created
by Dr. Ben Choi, Louisiana Technical University.
•I have modi fied them and adde d new slides
CSCE 310J: Data Structu res & Algorithms
3
Abstract Data Type
IAbstract Data Type
•Data Structure declaration
•Operations performed on the data structure
–e.g., create, destroy, or manipulate
–These are logical operations that are independent of the actual
implementation!
IProvides data encapsulation (information hiding)
IAn ADT is implemented as a Class in languages such as
C++ and Java
IAlgorithms can be designed, specified, and proven correct
using the logical properties of ADTs
IPerformance analysis depends on the implementation!
4
ADT Specification
IThe specification of an ADT describes how the
operations (functions, proce dures, or methods) behave
in terms of Inputs and Outputs
IA specification of an operation consists of:
•Calling prototype
•Preconditions
•Postconditions
IThe calling prototype includes
•name of the operation
•parameters and their types
•return value and its types
IThe preconditions are statements
•assumed to be true when the operation is called.
IThe postconditions are statements
•assumed to be true when the operation returns.
5
Operations for ADT
IConstructors
•create a new object and return a reference to it
IAccess functions
•return information about an object, but do not modify it
IManipulat ion procedures
•modify an object, but do not return information
IDestructors
•deallocate an object
6
More on ADTs
IState of an object
•current value of its data
ISome books claim that constructors and manipulation
procedures should be describe d in terms of Acces s
functions
•Maybe…
IRecursive ADT
•if any of its access functions returns the same class as the ADT