Sei sulla pagina 1di 2

Data Types and Data Structures

Data type is a set of data values having predefned characteristics. Example data
types would be integer, foats, string and characters. Every individual data value
has a data type that tells us what sort of value it is.
The range of values that can be stored in each of these data types is defned by the
language and the computer hardware that you are using the high level language on.
Scalar Data types
A simple scalar! data type consists of a collection of ordered values and a set of
operations that can be performed on those values. The ", "## and $ava
programming languages refer to scalar types as primitive data types.
Structured data types
Structured data types hold a collection of data values. This collection will generally consist of the
primitive data types. Examples of this would include arrays, records (structs), classes and files.
These data types, which are created by programmers, are extremely important and are the
building block of data structures.
Data Structure
data structure is a collection (grouping) of simple or structured data types and a set of rules
(operations) for organising and accessing the collection. Some examples of data structures would
be! an array, structs, classes, lists, strings, stacks, "ueues, files and tables. The underlying theme
here is that each structure has a defined organisation and a set of rules that implement and control
the organisation.
Abstract Data Type
The abstract data type (#T) is an abstraction of a data structure.
n #T specifies!
#ata stored
$perations on the data
Error conditions associated with operations.
ADT Components
%rom this example we can see that an #T is made up of the following components!
name (the name of the #T)
The data type or the data types represented by a collection of data, which is structured in
some manner &each type has been previously defined in a #T (or it is a primitive type)'
%unctions that operate on the data &the functions will specify the domain (parameters) and
range (return type)'
(reconditions for each of the functions (not shown in the example)
(ost)conditions for each of the functions (not shown in the example)
Error conditions that we need to consider.
Each #T definition consists of the following three parts!
Data! This part describes the structure of the data used in the #T.
Operations! This part describes valid operations for this #T* hence it describes its interface.
+e use the special operation constructor ,create to describe the actions which are to be
performed once an entity of this #T is created and destructor / destroy to describe the actions
which are to be performed once an entity is destroyed. %or each operation the provided
arguments, as well as preconditions and post)conditions, are given.
Errors: This part describes the errors that can occur and how we are going to deal with these
errors.

Potrebbero piacerti anche