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

DATA STRUCTURES

and ALGORITHMS

Course Instructors: Mary Gift D. Dionson, LPT, MSCS


DATA STRUCTURES and ALGORITHMS STI West Negros University
Markh B. Jamandre, MSCS
Types of Data Structure

Linear Non-Linear
Elements are Elements are
accessed in a stored and
sequential order accessed in a non-
but may be stored sequential order.
unsystematically

Course Instructors: Mary Gift D. Dionson, LPT, MSCS


DATA STRUCTURES and ALGORITHMS STI West Negros University
Markh B. Jamandre, MSCS
ABSTRACT DATA TYPE

An abstract data type or ADT is a


logical description of how data is
viewed as well as the operations that
are allowed without regard to how
they will be implemented.

Course Instructors: Mary Gift D. Dionson, LPT, MSCS


DATA STRUCTURES and ALGORITHMS STI West Negros University
Markh B. Jamandre, MSCS
ADTs and PROGRAM DESIGN

Top Down:
- Decompose problem into sub-problems, then
decompose sub-problems
- Structure charts are common design tool

Bottom Up:
- Design a set of tools and use them to build a
solution to the problem
- The tools are the values and operations of ADTs

Course Instructors: Mary Gift D. Dionson, LPT, MSCS


DATA STRUCTURES and ALGORITHMS STI West Negros University
Markh B. Jamandre, MSCS
Why Use ADTs

• Code is easier to understand

• Implementations of ADTs can


be changed without requiring
changes to the program that
uses the ADTs

• ADT can be used in future


programs
Course Instructors: Mary Gift D. Dionson, LPT, MSCS
DATA STRUCTURES and ALGORITHMS STI West Negros University
Markh B. Jamandre, MSCS
Parts of an ADT

Public / External Private / Internal


(data and operations) (data and operations)

Course Instructors: Mary Gift D. Dionson, LPT, MSCS


DATA STRUCTURES and ALGORITHMS STI West Negros University
Markh B. Jamandre, MSCS
ADT: Values and Operations

• The values in the


type

• The set of
operations that
can be used on
values of that type

Course Instructors: Mary Gift D. Dionson, LPT, MSCS


DATA STRUCTURES and ALGORITHMS STI West Negros University
Markh B. Jamandre, MSCS
ADT Operations Categories

• Declare a variable of the type


• Allocate a variable of the type
• Operations on values
• Iterate through subcomponents

Course Instructors: Mary Gift D. Dionson, LPT, MSCS


DATA STRUCTURES and ALGORITHMS STI West Negros University
Markh B. Jamandre, MSCS
ADT Design Principle

• Maximize Cohesion
- Every ADT has single, well-defined
purpose

• Minimize Coupling
- Design classes so that changing one does
not break the other
- Minimize reliance of one class on another

Course Instructors: Mary Gift D. Dionson, LPT, MSCS


DATA STRUCTURES and ALGORITHMS STI West Negros University
Markh B. Jamandre, MSCS
Abstract Data Types

Course Instructors: Mary Gift D. Dionson, LPT, MSCS


DATA STRUCTURES and ALGORITHMS STI West Negros University
Markh B. Jamandre, MSCS
ADT: Linked List
Representation:

Definition:
Used for storing elements
where each is separate
object

Types:
Singly, double, circular
linked list

Course Instructors: Mary Gift D. Dionson, LPT, MSCS


DATA STRUCTURES and ALGORITHMS STI West Negros University
Markh B. Jamandre, MSCS
ADT: Stack
Representation: Operations:
Push and Pop

Definition:
An ordered list in
which the last element
added is the first
element retrieved or
removed. (LIFO)

Course Instructors: Mary Gift D. Dionson, LPT, MSCS


DATA STRUCTURES and ALGORITHMS STI West Negros University
Markh B. Jamandre, MSCS
ADT: Queue
Representation: Operations:
Enqueue (Insertion), Dequeue (Deletion)

Definition:
It is an ordered list in
which the first
element added is the
first element
retrieved or removed
(FIFO)
Course Instructors: Mary Gift D. Dionson, LPT, MSCS
DATA STRUCTURES and ALGORITHMS STI West Negros University
Markh B. Jamandre, MSCS
ADT: Tree
Representation: Operations:
Create, Insert, Search, Traversal

Definition:
Represents a
hierarchical nature
of a structure in a
graphical form

Course Instructors: Mary Gift D. Dionson, LPT, MSCS


DATA STRUCTURES and ALGORITHMS STI West Negros University
Markh B. Jamandre, MSCS
ADT: Heap
Representation: Types:
Max-Heap and Min-Heap

Definition:
A complete binary
tree where the value
of each of each
parent node is either
higher or lower than
the value of its child
Course Instructors: Mary Gift D. Dionson, LPT, MSCS
DATA STRUCTURES and ALGORITHMS STI West Negros University
Markh B. Jamandre, MSCS
ADT: Priority Queue
Representation: Operations:
Insertion, Deletion, Peeking, Extract

Definition:
A special type of
queue where
elements are
processed based
on their order

Course Instructors: Mary Gift D. Dionson, LPT, MSCS


DATA STRUCTURES and ALGORITHMS STI West Negros University
Markh B. Jamandre, MSCS
ADT: Set
Representation:
Types:
Unordered Set, Ordered Set
(In Java: HashSet, TreeSet, LinkedHashSet)

Operations:
Insertion, Remove, Access, Size
Definition:
A collection of
elements where
each element is
unique

Course Instructors: Mary Gift D. Dionson, LPT, MSCS


DATA STRUCTURES and ALGORITHMS STI West Negros University
Markh B. Jamandre, MSCS
ADT: Map
Representation: Usage:
Database indexing, network routing, web
programming
Types of Maps:
Hash Map, Tree Map, Linked Hash Map,
Trie Map, Bloom Filter Map
Definition:
A set of ordered
pairs where
elements are
known as keys
(identifiers) and
values (content)
Course Instructors: Mary Gift D. Dionson, LPT, MSCS
DATA STRUCTURES and ALGORITHMS STI West Negros University
Markh B. Jamandre, MSCS
ADT: Graph
Representation: Operations:
Check if element is present, graph traversal
(DFS/BFS), add elements, path finding

Definition:
Consist of a set of Graph Adjacency Matrix
vertices (or nodes)
and a set of edges
(relations) between
the pairs of vertices
Adjacency List Representation
Course Instructors: Mary Gift D. Dionson, LPT, MSCS
DATA STRUCTURES and ALGORITHMS STI West Negros University
Markh B. Jamandre, MSCS

You might also like