1. Data Structures & Algorithms
Lecture 1: Foundational Data
Structures
Ms. Joan Wakasa Murumba
2. Definitions
A data type simply refers to a defined kind of
data, that is, a set of possible values & basic
operations on those values.
When applied in programming languages, a
data type defines a set of values & the
allowable operations on those values.
Types of data in programming languages
include integers, floating point numbers or
characters, tuples, records, ADT, etc.
3. Definitions
Integers: Numbers that do not have decimal
places
Floating point number: A real number (that is,
a number that can contain a fractional part).
The following are floating-point numbers:
3.0 , -111.5 , ½ , 3E-5 etc.
4. A Tuple
A tuple is an ordered set of values.
The separator for each value is often a comma
(depending on the rules of the particular
language).
Common uses for the tuple as a data type are
(1) for passing a string of parameters from one
program to another, and (2) representing a set
of value attributes in a relational database.
5. A Tuple
An example of a tuple that emphasizes the
different data types that may exist within a
tuple data type: 17,*,2.49,Seven
The above example is sometimes referred to
as a 4-tuple, since it contains four values.
6. ADT
An Abstract Data type is defined as a
mathematical model of the data objects that
make up a data type as well as the functions
that operate on these objects.
A set of data values and associated
operations that are precisely specified
independent of any particular implementation
A data type is abstract in the sense that it is
independent of various concrete
implementations
7. Examples of Abstract Data Type
Common abstract data types (ADT)
typically implemented in programming
languages include:
Arrays,
Lists,
Queues,
Stacks and
Trees.
8. Data Types
Data types are important in computer
programmes because they classify data so
that a translator can reserve appropriate
memory storage to hold all possible values,
e.g. integers, real numbers, characters,
strings, and Boolean values
9. A Data Type Consists of:
A domain (a set of values)
A set of operations that may be applied to
the values.
10. Data Type Classification
Simple Data Type: This is where some data
items may be used singly
The simple data types are classified as
follows:
a. Character
b. Numeric integer
c. Numeric real
d. Boolean (logical).
Data Structures: May be combined together
and arranged to form other data items
11. Data Structure
A data structure is the implementation of an
abstract data type in a particular programming
language.
Data structures can also be referred to as “data
aggregate”.
A data structure is an organization of
information, usually in memory, for better
algorithm efficiency, such as queue, stack, list,
and tree, or conceptual unity, such as the name
and address of a person.
12. Data Structure
Data structures are collections of data values,
the relationships among them and functions or
operations that can be applied to that data.
Classification of Data Structures
Data structures are broadly divided into two:
Linear Data Structures
Non-Linear Data Structures.
13. Linear Data Structures
Linear data structures are data structures in
which individual data elements are stored and
accessed linearly in the computer memory.
Examples include: lists, stacks, queues and
arrays
14. Non-Linear Data Structures
A non-linear data structure, as the name
implies, is a data structure in which the data
items are not stored linearly in the computer
memory, but data items can be processed
using some techniques or rules.
Typical non-linear data structures are Trees.
15. Purposes of Data Structures
For implementation of databases, e.g.,
trees
Provide a means of handling large amounts of
data efficiently, e.g. Large database, indexing
services, etc.
Efficient data structures are a key to designing
efficient algorithms
16. A data structure example
Name Age Address Town position
Joshua 22 P. 0 BOX
2285
NYERI student
17. From the above data structure, data
types can be
Data item Data type
Name Text, string
Age Integer, number,
Address Text, Alpha-numeric
Town Text
Position Text
18. Take Away Assignment
Q1. Computer Storage and management is key
in programming and computing. Find out the
relationship it has with data structures and
algorithms. Use suitable illustrations
Q2. Discuss in details A Stack data structure,
giving its components, functions, operations,
strengths and weaknesses and applications
Assignment Due on 13th
July, 2014