Presentation is loading. Please wait.

Presentation is loading. Please wait.

Based on Sedgewick and Wayne

Similar presentations


Presentation on theme: "Based on Sedgewick and Wayne"— Presentation transcript:

1 Based on Sedgewick and Wayne
Abstract Data Types Richard Newman Based on Sedgewick and Wayne 1

2 Abstract Data Type A data type is a set of values and a collection of operations on those values An ADT is a data type that is accessed only through an interface The interface is declared in the *.h file, the implementation in *.cpp file(s), and the client(s) in *.cpp files with main(). A first class data type is one we can use in our programs like built-in types. 2

3 Example ADTs Stack, queue, deque, tree, sorted list, ...
Point, vector, complex number, matrix, ... Graph, digraph, ... 3

4 Example: Complex Numbers
Complex numbers may be represented as pairs (a,b) in Cartesian coordinate where x = a + bi, Or in polar coordinates as pairs (r,q) where r is the distance from the origin and q is the angle of the vector from the real axis and x=reiq Complex number are not typically built-in types

5 Example: Complex Numbers
Values are all real-valued pairs of numbers Operations can be the usual, add, subtract, multiply divide along with some others, like conjugation, roots, etc. Need to define these operations and overload +, -, *, / to make first class Also need to provide for assignment/copy, deletion, conversion to string, etc.

6 Next: Generics


Download ppt "Based on Sedgewick and Wayne"

Similar presentations


Ads by Google