Data Strctures - Array and its representation

ananya195642 9 views 16 slides Aug 26, 2024
Slide 1
Slide 1 of 16
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16

About This Presentation

The ppt describes array and its representation


Slide Content

Data Structure

Array Definition Representation and Analysis Single and Multidimensional Array Address Calculation

Array

Array D Z P 34 9 7 7 S 3 22 M

Array [0] D Z P S M [1] [2] [3] [4] [5] [6] [7] [8] 34 9 7 7 22 [0] [1] [2] [3] [4] [5] [6] [7] [8] 34 9 7 7 22 [0] [1] [2] [3] [4] [5] [6] [7] [8] Z D S P 501 503 500 502

Array Definition: An array is a finite , ordered and collection of homogeneous data elements.   Array as ADT: An array is an ADT whose objects are sequence of elements of the same type and the two operations performed on it are store and retrieve .

Array: Terminology Type: Type of an array represents the kind of data it is meant for. For instance, and array of integer, an array of character strings. Base: The base of an array is the address of the memory location where the first element of the array is located. Index: All the elements in an array can be referenced by a subscript like A i or A[ i ]. An index is always an integer value. Range of indices: Indices of array elements may change from a lower bound (L) to an uppar bound (U), and these bounds are called the boundaries of an array. Word: Word denotes the size of an element. In each memory location, a computer can store an element of word size W, say. The word size varies from machine to machine such as 1 byte to 8 bytes.

Array W 501 503 500 502 Physical Memory Base [0] D Z P S M [1] [2] [3] [4] [5] [6] [7] [8] S K R T Index char C[0:8] Size=9 34 9 7 7 22 [0] [1] [2] [3] [4] [5] 4 int I[0:5] Size=6 C [ l : u ]

Array Representation 1D 2D 3D

Array Representation 1D A [ l : u ]

Array Representation 2D A [ l 1 : u 1 , l 2 : u 2 ] row1 row2 row3 row4 col1 col5 A [ 1 : 4, 1 : 5 ]

Array Representation 3D A [ l 1 : u 1 , l 2 : u 2, l 3 : u 3 ] l 1 : u 1 l 3 : u 3 l 2 : u 2

Array: No of Elements 1D In an 1D array, A[ l:u ], the number of elements is given by (u-l+1) A [ l : u ]

Array: No of Elements 2D A [ l 1 : u 1 , l 2 : u 2 ] row1 row2 row3 row4 col1 col5 In a 2D array, A[ l:u ], the number of elements is given by (u 1 -l 1 +1)(u 2 -l 2 +1)

Array: No of Elements A [ l 1 : u 1 , l 2 : u 2, . . . , l n : u n ] In a 2D array, A[ l:u ], the number of elements is given by