Professional Documents
Culture Documents
Data Structure
Data Structure
Data Structure
my
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
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
5
http://fskik.upsi.edu.my
6
http://fskik.upsi.edu.my
Algorithm
3 types of algorithm basic control structure
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
Unsorted
Queue tree
linked list
Sorted
Stack graph
linked list
11
http://fskik.upsi.edu.my
12
http://fskik.upsi.edu.my
getBookInfo()
checkAuthor()
checkPrice()
checkPublisher()
Abstraction of a book
13
http://fskik.upsi.edu.my
Data Type
ADT:
Type Data Items:
Operations Logical Form
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