ADT Example

Example Data Types: Integer, and Character


Example (Integer Data Type)

The integer data type can consist of:
data values: −∞,...,−2,−1,0,1,2,...,∞

operations: +,−,∗,%,/,...


Example (Character Data Type)
The character data type can consist of:
data values: \0,..., ’A’,’B’,...,’a’,’b’,..., ’1’, ’2’, ...

operations: <, >, ≤, ≥, ==, ...


Example Data Types: Person, and 2D Points
We can have data types for composite data too.


Example (Person Data Type)
The Person data type can consist of:
data values: { 15, "Bob", "Buckwheat"}, { 50, "Jack", "Bauer" },
...
operations: set/get firstname, set/get lastname, set/get age,
==, ...


Example (2D Point Data Type)


The 2D Point data type can consist of:
data values: (0,0),(1,0),(3.7,−8.5)···
operations: get distance between 2 points, move point, add
points together, ...


Data Structures: Familiar examples


Example (Data Structure: Array)


Elements: All the same data type (integer, float, Person,
etc,.).
Structure: Elements form a contiguous sequence in which
each element is numbered with an index.


Example (Data Structure: Matrix (2D array))
Elements: All the same data type (integer, float, Person,
etc,.).
Structure: Elements form a grid in which each element has a
row and column position.

posted @ 2016-01-22 13:03  blfshiye  阅读(102)  评论(0编辑  收藏  举报