230 likes | 313 Views
Foundation of Computing Systems. Lecture 1 Arrays and Matrices. Arrays. An array is a finite, ordered and collection of homogeneous data elements Finite: because it contains only limited number of elements
E N D
Foundation of Computing Systems Lecture 1 Arrays and Matrices
Arrays • An array is a finite, ordered and collection of homogeneous data elements • Finite: because it contains only limited number of elements • Ordered: as all the elements are stored one by one in contiguous locations of computer memory in a linear ordered fashion • Homogeneous: all elements of an array are of the same data type only IT 60101: Lecture #1
Arrays: Example IT 60101: Lecture #1
Arrays: Example Address (A[i]) = M + (i – L) x w Size (A) = U – L + 1 IT 60101: Lecture #1
Arrays: Operations • Swap • Traversal • Insertion • Deletion • Merging IT 60101: Lecture #1
Arrays: Operations • Swap • Traversal • Insertion • Deletion • Merging IT 60101: Lecture #1
Arrays: Operations • Swap • Traversal Searching • Insertion • Deletion • Merging IT 60101: Lecture #1
Arrays: Operations • Swap • Traversal • Insertion • Deletion • Merging IT 60101: Lecture #1
Arrays: Operations • Swap • Traversal • Insertion • Deletion • Merging IT 60101: Lecture #1
Arrays: Operations • Swap • Traversal • Insertion • Deletion • Merging IT 60101: Lecture #1
Multidimensional Arrays • More than one indexing to specify a location • 2-D: row, column • 3-D: row, column, height etc. IT 60101: Lecture #1
Matrix: A 2-D Arrays • Two-dimensional arrays (alternatively termed as matrices) are the collection of homogeneous elements where the elements are ordered in a number of rows and columns • Indexing: row, column IT 60101: Lecture #1
Matrix: Memory Representations • Row-major order Address (aij) = M + (i – 1) x n + j – 1 • Column-major order Address (aij) = M + (j – 1) x m + i – 1 IT 60101: Lecture #1
Sparse Matrix • A sparse matrix is a two-dimensional array having the value of majority elements as null IT 60101: Lecture #1
Sparse Matrix IT 60101: Lecture #1
Triangular Sparse Matrices IT 60101: Lecture #1
Diagonal Sparse Matrices IT 60101: Lecture #1
Tri-Diagonal Sparse Matrices IT 60101: Lecture #1
Band Matrices IT 60101: Lecture #1
Memory Representation of Sparse Matrices • Lower triangular matrix • Row-major order • Column-major order Address (aij) = IT 60101: Lecture #1
Memory Representation of Tridiagonal Matrices • Tri-diagonal matrix • Row-major order Address (aij) = M + 2 x (i – 2) + j + 1 • Column-major order Address (aij) = M + 2 x(j – 2) + i + 1 IT 60101: Lecture #1
Memory Representation of band matrix • Band matrix • Row-major order • ? • Column-major order • ? IT 60101: Lecture #1
Pointer Arrays • Address of memory variable or array is known as pointer and an array containing pointers as its elements is known as pointer array IT 60101: Lecture #1