Professional Documents
Culture Documents
Data Struc
Data Struc
be classified
• To understand the most commonly used, basic
data types and data arrays
• To understand the characteristics and
mechanisms of problem-oriented data
structures used to solve specific problems, as
well as how to use a basic data structure for
program implementation
What is Data Structure?
Data Structure is a set of the same kind of
data processed by a computer.
It is a way of organizing data that considers
not only the items stored but also the relationship
of each data.
Integer Hash
Logical
Real Number
Enumeration
Character
Partial
Basic Data Type Simple Type
ArrayX [ j ]
Element / Subscript / Index
Array Name
Structured Type Array Type
Example:
Grade [ j ] Grade [ 0 ] = 95
Grade [ 5 ] Grade [ 1 ] = 85
Grade [ 2 ] = 75
Grade [ 3 ] = 100
Grade [ 4 ] = 65
Structured Type Array Type
int ArrayX [ j , k ]
Base type index
Array Name
Structured Type Array Type
ANSWER:
Loc[1980] = 1041
NE = 65
Exercise
Given a 4x5 array with [-3..0, 2..6) index,
starting address is 81 with 2 words per memory
cell. Locate [-1,5] using row major and column
major representation.
To get the number of elements in an array
M = UB1 – LB1 + 1 NE = M x N
N = UB2 – LB2 + 1
-3 81 83 85 87 89
R -2 91 93 95 97 99
O
W
-1 101 103 105 107 109 ROW MAJOR
Locate
0 111 113 115 117 119
BACK
Memory Map
COLUMN
2 3 4 5 6
-3 81 89 97 105 113
R -2 83 91 99 107 115
O
W
-1 85 93 101 109 117 COLUMN MAJOR
Locate
0 87 95 103 111 119
BACK
Exercise
When storing a two-dimensional array “a” with ten
rows and ten columns in continuous memory space in
the direction of rows, what is the address where a [5,6] is
stored? In this question, the address is represented in
decimal numbers.
Address
100
a [1,1]
101
102
a [1,2]
103
NODE
DATA POINTER
Data FIELD FIELD
Address
Problem-Oriented Data Structure
Types of List Structure
Uni-directional List
HEAD TAIL
Problem-Oriented Data Structure
Types of List Structure
Bi-directional List
01H 05H 03H
HEAD
07H
TAIL
Problem-Oriented Data Structure
STACK
An ordered list where all operations are
restricted at one end of the list known as TOP.
List processing is based on Last-In First-Out
(LIFO).
Top
Bottom
Problem-Oriented Data Structure
STACK OPERATION
1. Pop (S)
2. Push (E,S) D
3. Push (F,S)
C
4. Pop (S)
5. Pop (S) B
6. Push (G) A
Problem-Oriented Data Structure
STACK APPLICATION
POSTFIX - an expression
where operator is placed
after the operands
Example : (AB+)
Exercise
Convert the following mathematical
expression into INFIX, PREFIX, and POSTFIX
Notation.
A Binary Tree
/
B C D
* +
E F G H I J
A B C D
K L M
Exercise
Create a Tree Structure based on the given
prefix and postfix notation.
1.) - + / *A B G M * ^ N 3 - + G H ^ I 2
2.) FM3^*S/K*M3^L*-QP2^*+