Data Structure

You might also like

You are on page 1of 17

http://fskik.upsi.edu.

my

Introduction to Data Structures

MTS3023
Data Structure

1
http://fskik.upsi.edu.my

What is Program?
 A Set of instructions
 Data Structures + Algorithms
 Data Structure = A container stores data
 Algorithm = Logic and Control

2
http://fskik.upsi.edu.my

Common Data Structures


 Array + Pointer
 Stack
 Queue
 Linked List
 Tree
 Heap
 Hash Table
 Priority Queue

3
http://fskik.upsi.edu.my

Algorithm Strategies
 Greedy
 Divide and Conquer
 Dynamic Programming
 Exhaustive Search

4
http://fskik.upsi.edu.my

Algorithm
 step-by-step recipe for performing a task
 operate on a collection of data
 problem solving using logic

Input Process Output

5
http://fskik.upsi.edu.my

Example Algorithm Vending


Machine

6
http://fskik.upsi.edu.my

Algorithm
 3 types of algorithm basic control structure

Sequential Selection Repetition

 Basic algorithm characteristics


Finite Clear Has Has Operate
Solution Instruction Input Output Effectively

7
http://fskik.upsi.edu.my

Efficiency of Algorithm
• The techniques to design algorithm are such
as:
– Flowchart, pseudo code
• Factors for measuring good algorithms

Time Space

Cost

8
http://fskik.upsi.edu.my

Data Structure
Insertion
Merging Deletion
Operations

Traversing Sorting

Searching

9
http://fskik.upsi.edu.my

Data Types
Basic data types
 Data Types
Structured data types
 Data Structures – the physical
implementation of an ADT (Abstract Data
Type)
 Data Structures – an organization for data
in main memory.
 File Structures – an organization for data
on peripheral storage such as a disk drive
10
http://fskik.upsi.edu.my

Linked Data Structure


Linear Data Linear Data Non-Linear
Structures Structures Data
with restriction with no Structures
restriction

Unsorted
Queue tree
linked list

Sorted
Stack graph
linked list

11
http://fskik.upsi.edu.my

Abstract Data Types (ADT)


ADT: Data
members
Data
Data
ADT operation
Members
Operation
function/
methods

Each ADT operation is defined by its inputs and


outputs

12
http://fskik.upsi.edu.my

Abstract Data Type - Example


book
Titte
Year
Author
Publisher
abstract to price

getBookInfo()
checkAuthor()
checkPrice()
checkPublisher()

Abstraction of a book

13
http://fskik.upsi.edu.my

Data Type

ADT:
Type Data Items:
Operations Logical Form

Data Structure: Data Items:


Storage Space Physical Form
Subroutines

14
http://fskik.upsi.edu.my

Questions
1. What is the definition of a data type?
2. In addition to the four arithmetic operations,
what are some other operations that are
typically defined for the integer data type?
3.Why does it make sense to extend the
definition of data types to include data
structures?

15
http://fskik.upsi.edu.my

Questions
4. What are the three ADTs that we studied in
this section?
5. What two elements are required for an
ADT?
6. Why are ADTs abstract?
7. How do we define an interface for an ADT?
8. Is it necessary to know how an ADT is
implemented in order to use it?

16
http://fskik.upsi.edu.my

Questions
9. Describe the purpose of each of the following
bag operations.

1. PutItem
2. GetItem
3. IsEmpty
4. IsFull
5. GrabAnItem
6. HasItem
7. TotalItems
8. EmptyTheBag

17

You might also like