SlideShare a Scribd company logo
Unit-2
Linear Data
Structure
Array
Data Structures (DS)
GTU # 3130702
✓ Loopin
g
Outline
▪ Array
• Representation of arrays
• One dimensional array
• Two dimensional array
▪ Applications of arrays
• Symbol Manipulation (matrix representation of
polynomial equation)
• Sparse matrix
▪ Sparse matrix and its representation
One Dimensional Array
🞂 Simplest data structure that makes use of computed address to locate its
elements is the one-dimensional array or vector.
🞂 Number of memory locations is sequentially allocated to the vector.
🞂 A vector size is fixed and therefore requires a fixed number of memory
locations.
🞂 Vector A with subscript lower bound of “one” is represented as below….
• L0 is the address of the first word allocated to the first element of vector A
• C words is size of each element or node
• The address of element Ai is
Loc(Ai) = L0 + (C*(i-1))
• Let’s consider the more general case of a vector A with lower bound for it’s
subscript is given by some variable b.
• The address of element Ai is
Loc(Ai) = L0 + (C*(i-b))
A[i]
L
0
L0+(i-1)C
i-1
Two Dimensional Array
🞂 Two dimensional arrays are also called table or matrix
🞂 Two dimensional arrays have two subscripts
🞂 Column major order matrix: Two dimensional array in which elements are
stored column by column is called as column major matrix
🞂 Two dimensional array consisting of two rows and four columns is stored
sequentially by columns :
A[1,1],
A[2,1],
A[1,2],
A[2,2],
A[1,3],
A[2,3],
A[1,4],
A[2,4]
[1,1] [1,2] [1,3] [1,4]
[2,1] [2,2] [2,3] [2,4]
Row
1
Row
2
Col-
1
Col-
2
Col-
3
Col-
4
Column major order matrix
🞂 The address of element A [ i , j ] can be obtained by expression
Loc (A [ i , j ]) = L0 + (j-1)*2 + (i-1)
Loc (A [2, 3]) = L0 + (3-1)*2 + (2-1) = L0 + 5
🞂 In general for two dimensional array consisting of n rows and m columns the
address element A [ i , j ] is given by
Loc (A [ i , j ]) = L0 + (j-1)*n + (i – 1)
[1,1] [1,2] [1,3] [1,4]
[2,1] [2,2] [2,3] [2,4]
Row
1
Row
2
Col-
1
Col-
2
Col-
3
Col-
4
[1,1]
[2,1]
[1,2]
[2,2]
[1,3]
Applications of Array
1. Symbol Manipulation (matrix representation of polynomial equation)
2. Sparse Matrix
🞂 Matrix representation of polynomial equation
⮩ We can use array for different kind of operations in polynomial equation such as addition,
subtraction, division, differentiation etc…
⮩ We are interested in finding suitable representation for polynomial so that different
operations like addition, subtraction etc… can be performed in efficient manner.
⮩ Array can be used to represent Polynomial equation.
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
X
X2
X3
X4
Y Y2
Y3 Y4
Representation of Polynomial equation
2X2
+ 5XY + Y2
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
X
X2
X3
X4
Y Y2
Y3 Y4
2
5
1
X2
+ 3XY + Y2
+Y-X
1
3
1
1
-1
Y Y2
Y3 Y4
X XY XY2
XY3
XY4
X2
X3
Y X2
Y2
X2
Y3
X2
Y4
X3
X3
Y X3
Y2
X3
Y3
X3
Y4
X4 X4
Y X4
Y2
X4
Y3
X4
Y4
Sparse matrix
🞂 An m x n matrix is said to be sparse if “many” of its elements are zero.
🞂 A matrix that is not sparse is called a dense matrix.
🞂 We can device a simple representation scheme whose space requirement
equals the size of the non-zero elements.
0 0 0 2 0 0 1 0
0 6 0 0 7 0 0 3
0 0 0 9 0 8 0 0
0 4 5 0 0 0 0 0
Terms
Row
Column
Value
4x8
Row - 1
Row - 2
Row - 3
Row - 4
Column
-
1
C
olumn
-
2
C
olumn
-
3
C
olumn
-
4
C
olumn
-
5
C
olumn
-
6
C
olumn
-
7
C
olumn
-
8
Linear Representation of given matrix
0
1
4
2
1
1
7
1
2
2
2
6
3
2
5
7
4
2
8
3
5
3
4
9
6
3
6
8
7
4
2
4
8
4
3
5
Sparse matrix Cont…
🞂 To construct matrix structure from liner representation we need to record.
⮩ Original row and columns of each non zero entries.
⮩ Number of rows and columns in the matrix.
🞂 So each element of the array into which the sparse matrix is mapped need to
have three fields: row, column and value
Sparse matrix Cont…
0 0 6 0 9 0 0
2 0 0 7 8 0 4
10 0 0 0 0 0 0
0 0 12 0 0 0 0
0 0 0 0 0 0 0
0 0 0 3 0 0 5
Row Colum
n
A
6x7
1
2
3
4
5
6
1 2 3 4 5 6 7
Memory Space required to
store
6x7 matrix
42 x 2 = 84 bytes
Memory Space required to
store
Linear Representation
30 x 2 = 60 bytes
Linear representation of
Matrix
A =
1 3 6
1 5 9
2 1 2
2 4 7
2 5 8
2 7 4
3 1 10
4 3 12
6 4 3
6 7 5
Space Saved = 84 – 60 = 24 bytes
Sparse matrix Cont…
Row
1
1
2
2
2
2
3
4
6
6
Colum
n
3
5
1
4
5
7
1
3
4
7
A
6
9
2
7
8
4
10
12
3
5
Linear Representation of
Matrix Colum
n
3
5
1
4
5
7
1
3
4
7
A
6
9
2
7
8
4
10
12
3
5
Linear Representation of
Matrix
Row
1
3
7
8
0
9
1
2
3
4
5
6
7
8
9
10
1
2
3
4
5
6
Memory Space required to store Liner Representation = 26 x 2 = 42 bytes

More Related Content

Similar to Data strutcure and annalysis topic array (20)

PPTX
data structure and algorithm Array.pptx btech 2nd year
palhimanshi999
 
PPT
Two Dimensional Array
dincyjain
 
PPTX
arrays.pptx
HarmanShergill5
 
PDF
cluod.pdf
ssuser92d367
 
PDF
2ds
anumrasheed
 
PDF
Multi dimensional array
Rajendran
 
PPT
Matrix Algebra : Mathematics for Business
Khan Tanjeel Ahmed
 
PPTX
arrays in data structure.pptx
KasthuriKAssistantPr
 
PPT
ArrayBasics.ppt
RaselAzam1
 
PPTX
SORTTING IN LINEAR TIME - Radix Sort
Devanshu Taneja
 
PPTX
Arrays
DebiPrasadSen
 
PPTX
Sparse matrix and its representation data structure
Vardhil Patel
 
PPTX
arrays.pptx
NehaJain919374
 
PDF
BCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHI
Sowmya Jyothi
 
PDF
13. Pointer and 2D array
Gem WeBlog
 
PPTX
matrix algebra
kganu
 
PPTX
Lecture 3 data structures and algorithms
Aakash deep Singhal
 
PPTX
Introduction to matlab lecture 2 of 4
Randa Elanwar
 
PPTX
6.3 matrix algebra
math260
 
PDF
R_CheatSheet.pdf
MariappanR3
 
data structure and algorithm Array.pptx btech 2nd year
palhimanshi999
 
Two Dimensional Array
dincyjain
 
arrays.pptx
HarmanShergill5
 
cluod.pdf
ssuser92d367
 
Multi dimensional array
Rajendran
 
Matrix Algebra : Mathematics for Business
Khan Tanjeel Ahmed
 
arrays in data structure.pptx
KasthuriKAssistantPr
 
ArrayBasics.ppt
RaselAzam1
 
SORTTING IN LINEAR TIME - Radix Sort
Devanshu Taneja
 
Sparse matrix and its representation data structure
Vardhil Patel
 
arrays.pptx
NehaJain919374
 
BCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHI
Sowmya Jyothi
 
13. Pointer and 2D array
Gem WeBlog
 
matrix algebra
kganu
 
Lecture 3 data structures and algorithms
Aakash deep Singhal
 
Introduction to matlab lecture 2 of 4
Randa Elanwar
 
6.3 matrix algebra
math260
 
R_CheatSheet.pdf
MariappanR3
 

Recently uploaded (20)

PPTX
Fluvial_Civilizations_Presentation (1).pptx
alisslovemendoza7
 
PDF
Classifcation using Machine Learning and deep learning
bhaveshagrawal35
 
PDF
An Uncut Conversation With Grok | PDF Document
Mike Hydes
 
PPTX
Introduction to Data Analytics and Data Science
KavithaCIT
 
PPTX
Presentation (1) (1).pptx k8hhfftuiiigff
karthikjagath2005
 
PPTX
World-population.pptx fire bunberbpeople
umutunsalnsl4402
 
PPTX
Solution+Architecture+Review+-+Sample.pptx
manuvratsingh1
 
PPTX
7 Easy Ways to Improve Clarity in Your BI Reports
sophiegracewriter
 
PDF
Top Civil Engineer Canada Services111111
nengineeringfirms
 
PDF
717629748-Databricks-Certified-Data-Engineer-Professional-Dumps-by-Ball-21-03...
pedelli41
 
PPTX
Probability systematic sampling methods.pptx
PrakashRajput19
 
PDF
McKinsey - Global Energy Perspective 2023_11.pdf
niyudha
 
PPT
introdution to python with a very little difficulty
HUZAIFABINABDULLAH
 
PDF
blockchain123456789012345678901234567890
tanvikhunt1003
 
PDF
202501214233242351219 QASS Session 2.pdf
lauramejiamillan
 
PDF
WISE main accomplishments for ISQOLS award July 2025.pdf
StatsCommunications
 
PDF
apidays Munich 2025 - Integrate Your APIs into the New AI Marketplace, Senthi...
apidays
 
PPTX
MR and reffffffvvvvvvvfversal_083605.pptx
manjeshjain
 
PPTX
Customer Segmentation: Seeing the Trees and the Forest Simultaneously
Sione Palu
 
PDF
apidays Munich 2025 - Developer Portals, API Catalogs, and Marketplaces, Miri...
apidays
 
Fluvial_Civilizations_Presentation (1).pptx
alisslovemendoza7
 
Classifcation using Machine Learning and deep learning
bhaveshagrawal35
 
An Uncut Conversation With Grok | PDF Document
Mike Hydes
 
Introduction to Data Analytics and Data Science
KavithaCIT
 
Presentation (1) (1).pptx k8hhfftuiiigff
karthikjagath2005
 
World-population.pptx fire bunberbpeople
umutunsalnsl4402
 
Solution+Architecture+Review+-+Sample.pptx
manuvratsingh1
 
7 Easy Ways to Improve Clarity in Your BI Reports
sophiegracewriter
 
Top Civil Engineer Canada Services111111
nengineeringfirms
 
717629748-Databricks-Certified-Data-Engineer-Professional-Dumps-by-Ball-21-03...
pedelli41
 
Probability systematic sampling methods.pptx
PrakashRajput19
 
McKinsey - Global Energy Perspective 2023_11.pdf
niyudha
 
introdution to python with a very little difficulty
HUZAIFABINABDULLAH
 
blockchain123456789012345678901234567890
tanvikhunt1003
 
202501214233242351219 QASS Session 2.pdf
lauramejiamillan
 
WISE main accomplishments for ISQOLS award July 2025.pdf
StatsCommunications
 
apidays Munich 2025 - Integrate Your APIs into the New AI Marketplace, Senthi...
apidays
 
MR and reffffffvvvvvvvfversal_083605.pptx
manjeshjain
 
Customer Segmentation: Seeing the Trees and the Forest Simultaneously
Sione Palu
 
apidays Munich 2025 - Developer Portals, API Catalogs, and Marketplaces, Miri...
apidays
 
Ad

Data strutcure and annalysis topic array

  • 2. ✓ Loopin g Outline ▪ Array • Representation of arrays • One dimensional array • Two dimensional array ▪ Applications of arrays • Symbol Manipulation (matrix representation of polynomial equation) • Sparse matrix ▪ Sparse matrix and its representation
  • 3. One Dimensional Array 🞂 Simplest data structure that makes use of computed address to locate its elements is the one-dimensional array or vector. 🞂 Number of memory locations is sequentially allocated to the vector. 🞂 A vector size is fixed and therefore requires a fixed number of memory locations. 🞂 Vector A with subscript lower bound of “one” is represented as below…. • L0 is the address of the first word allocated to the first element of vector A • C words is size of each element or node • The address of element Ai is Loc(Ai) = L0 + (C*(i-1)) • Let’s consider the more general case of a vector A with lower bound for it’s subscript is given by some variable b. • The address of element Ai is Loc(Ai) = L0 + (C*(i-b)) A[i] L 0 L0+(i-1)C i-1
  • 4. Two Dimensional Array 🞂 Two dimensional arrays are also called table or matrix 🞂 Two dimensional arrays have two subscripts 🞂 Column major order matrix: Two dimensional array in which elements are stored column by column is called as column major matrix 🞂 Two dimensional array consisting of two rows and four columns is stored sequentially by columns : A[1,1], A[2,1], A[1,2], A[2,2], A[1,3], A[2,3], A[1,4], A[2,4] [1,1] [1,2] [1,3] [1,4] [2,1] [2,2] [2,3] [2,4] Row 1 Row 2 Col- 1 Col- 2 Col- 3 Col- 4
  • 5. Column major order matrix 🞂 The address of element A [ i , j ] can be obtained by expression Loc (A [ i , j ]) = L0 + (j-1)*2 + (i-1) Loc (A [2, 3]) = L0 + (3-1)*2 + (2-1) = L0 + 5 🞂 In general for two dimensional array consisting of n rows and m columns the address element A [ i , j ] is given by Loc (A [ i , j ]) = L0 + (j-1)*n + (i – 1) [1,1] [1,2] [1,3] [1,4] [2,1] [2,2] [2,3] [2,4] Row 1 Row 2 Col- 1 Col- 2 Col- 3 Col- 4 [1,1] [2,1] [1,2] [2,2] [1,3]
  • 6. Applications of Array 1. Symbol Manipulation (matrix representation of polynomial equation) 2. Sparse Matrix 🞂 Matrix representation of polynomial equation ⮩ We can use array for different kind of operations in polynomial equation such as addition, subtraction, division, differentiation etc… ⮩ We are interested in finding suitable representation for polynomial so that different operations like addition, subtraction etc… can be performed in efficient manner. ⮩ Array can be used to represent Polynomial equation.
  • 7. 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 X X2 X3 X4 Y Y2 Y3 Y4 Representation of Polynomial equation 2X2 + 5XY + Y2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 X X2 X3 X4 Y Y2 Y3 Y4 2 5 1 X2 + 3XY + Y2 +Y-X 1 3 1 1 -1 Y Y2 Y3 Y4 X XY XY2 XY3 XY4 X2 X3 Y X2 Y2 X2 Y3 X2 Y4 X3 X3 Y X3 Y2 X3 Y3 X3 Y4 X4 X4 Y X4 Y2 X4 Y3 X4 Y4
  • 8. Sparse matrix 🞂 An m x n matrix is said to be sparse if “many” of its elements are zero. 🞂 A matrix that is not sparse is called a dense matrix. 🞂 We can device a simple representation scheme whose space requirement equals the size of the non-zero elements. 0 0 0 2 0 0 1 0 0 6 0 0 7 0 0 3 0 0 0 9 0 8 0 0 0 4 5 0 0 0 0 0 Terms Row Column Value 4x8 Row - 1 Row - 2 Row - 3 Row - 4 Column - 1 C olumn - 2 C olumn - 3 C olumn - 4 C olumn - 5 C olumn - 6 C olumn - 7 C olumn - 8 Linear Representation of given matrix 0 1 4 2 1 1 7 1 2 2 2 6 3 2 5 7 4 2 8 3 5 3 4 9 6 3 6 8 7 4 2 4 8 4 3 5
  • 9. Sparse matrix Cont… 🞂 To construct matrix structure from liner representation we need to record. ⮩ Original row and columns of each non zero entries. ⮩ Number of rows and columns in the matrix. 🞂 So each element of the array into which the sparse matrix is mapped need to have three fields: row, column and value
  • 10. Sparse matrix Cont… 0 0 6 0 9 0 0 2 0 0 7 8 0 4 10 0 0 0 0 0 0 0 0 12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 0 0 5 Row Colum n A 6x7 1 2 3 4 5 6 1 2 3 4 5 6 7 Memory Space required to store 6x7 matrix 42 x 2 = 84 bytes Memory Space required to store Linear Representation 30 x 2 = 60 bytes Linear representation of Matrix A = 1 3 6 1 5 9 2 1 2 2 4 7 2 5 8 2 7 4 3 1 10 4 3 12 6 4 3 6 7 5 Space Saved = 84 – 60 = 24 bytes
  • 11. Sparse matrix Cont… Row 1 1 2 2 2 2 3 4 6 6 Colum n 3 5 1 4 5 7 1 3 4 7 A 6 9 2 7 8 4 10 12 3 5 Linear Representation of Matrix Colum n 3 5 1 4 5 7 1 3 4 7 A 6 9 2 7 8 4 10 12 3 5 Linear Representation of Matrix Row 1 3 7 8 0 9 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 Memory Space required to store Liner Representation = 26 x 2 = 42 bytes