Download as pdf or txt
Download as pdf or txt
You are on page 1of 20

OVERVIEW OF DATA

STRUCTURES
Introductory Concepts on Data Structures
What are Data Structures?
Ways of storing data
Our Main Focus: storage in main memory(RAM)
They enable efficient use of data and/or simplify
certain algorithms.
Example 1: Queues

As the name implies: a


first-in, first-out(FIFO) list
Application examples:
Queuing requests in
large-scale systems (e.g.
web-servers, SMS
gateways, call center ...)
Event scheduling and
simulation
Example 2: Graphs

Nodes connected using


edges
Can be used to model
numerous situations such
as:
Social Networks(facebook,
twitter, ...)
Internet Routing
Web Search
Example 2: Graphs(Social Networks)

Nodes: people
Edges: "friendships"
Example 2: Graphs(The Internet)

Nodes: Computers, switches, routers and other active


devices
Edges: Connection between these active devices
The basis for routing algorithms
Example 3: A Binary Tree
A binary tree is organized like an
upside down tree.
Each spot on the tree, called a node,
holds an item of data along with a
left pointer and a right pointer.
The pointers are lined up so that the
structure forms the upside down tree,
with a single node at the top, called
the root node, and branches Binary Tree
increasing on the left and right as
you go down the tree.
Data Abstraction
Data Types are data abstractions provided by the
programming language
Example: integer data type
You don't have to worry about the representation of
integers in memory (two's complement, sign and
magnitude ...)
You also don't have worry about the memory
addressing system
Likewise, you don't have to know how the arithmetic
operations are performed in the CPU
What Exactly is Data Abstraction?
Way of expressing data in with a representation
similar inform to its meaning
Implementation Details are hidden from the user.
Enables us to limit our focus to the problem domain
Reduced complexity
Abstract Data Types(ADTs)
Enables us to create data abstractions that
represent more complex data structures
Throughout this course we will be asking: how can I
create ADTs that represent specific data
structures(such as queues and graphs)?
OOP is a great way to create these abstractions
Choosing Data Structures
By comparing the queue with the
binary tree, you can see how the
structure of the data affects what
can be done efficiently with the
data.
Choosing Data Structures
A queue is a good data structure to
use for storing things that need to be
kept in order, such as a set of
documents waiting to be printed on a
network printer.

.
Choosing Data Structures
The jobs will be printed in the order
in which they are received.

Most network print servers maintain


such a print queue.

.
Choosing Data Structures
A binary tree is a good data
structure to use for searching sorted
data.

The middle item from the list is stored


in the root node, with lesser items to
the left and greater items to the right.
Choosing Data Structures
A search begins at the root. The
computer either find the data, or
moves left or right, depending on the
value for which you are searching.

Each move down the tree cuts the


remaining data in half.
Choosing Data Structures
Items can be located very quickly in a
tree.
Telephone directory assistance
information is stored in a tree, so that
a name and phone number can be
found quickly.
Choosing Data Structures
For some applications, a queue is the
best data structure to use.
For others, a binary tree is better.
Programmers choose from among
many data structures based on how
the data will be used by the program.
Operations on Data Structures
Different Operations on different data structures.
The Operations arise from the structural behavior of
the data structure
The implementation and names of operations
slightly vary from one programming language to
the other.
Just to see few examples of operations on data
structures.
First Example: Queue
19

FIFO: First In First Out


Queue operations
create
destroy
dequeue
enqueue G enqueue FEDCB A
dequeue
is_empty

Data Structures - Introduction


Second Example: Stack ADT
20

LIFO: Last In First Out


Stack operations
create
destroy A EDCBA
push
pop B
top C
D
is_empty
E
F F

Data Structures - Introduction

You might also like