SlideShare a Scribd company logo
1 of 49
Data Structure and Algorithm
CS-102
Ashok K Turuk
1
Data Structure
vs
Storage Structure
• Data Structure : The logical or mathematical
model of a particular organization of data
• Storage Structure : Representation of a
particular data structure in the memory of a
computer
• There are many possible storage structure to a
particular data structure
• Ex: there are a number of storage structure for a data
structure such as array
– It is possible for two DS to represented by the
same storage structure
2
Classification
• Data Structure
– Linear
– Non-Linear
• A Data structure is said to be linear if
its elements from a sequence or in other
words form a linear list
3
Representation in Memory
• Two basic representation in memory
– Have a linear relationship between the
elements represented by means of
sequential memory locations [ Arrays]
– Have the linear relationship between the
elements represented by means of pointer
or links [ Linked List]
4
Operation on Linear Structure
• Traversal : Processing each element in the list
• Search : Finding the location of the element
with a given value or the record with a given
key
• Insertion: Adding a new element to the list
• Deletion: Removing an elements from the list
• Sorting : Arranging the elements in some type
of order
• Merging : Combining two list into a single list
5
Array
6
Linear Arrays
• A linear array is a list of a finite
number of n homogeneous data
elements ( that is data elements of the
same type) such that
– The elements are of the arrays are
referenced respectively by an index set
consisting of n consecutive numbers
– The elements of the arrays are stored
respectively in successive memory
locations
7
Linear Arrays
• The number n of elements is called the
length or size of the array.
• The index set consists of the integer 1,
2, … n
• Length or the number of data elements of
the array can be obtained from the index
set by
Length = UB – LB + 1 where UB is the
largest index called the upper bound and
LB is the smallest index called the lower
bound of the arrays
8
Linear Arrays
• Element of an array A may be denoted
by
– Subscript notation A1, A2, , …. , An
– Parenthesis notation A(1), A(2), …. , A(n)
– Bracket notation A[1], A[2], ….. , A[n]
• The number K in A[K] is called subscript
or an index and A[K] is called a
subscripted variable
9
Representation of Linear Array in Memory
10
1000
1001
1002
1003
1004
1005
Computer Memory
:
Representation of Linear Array in Memory
• Let LA be a linear array in the memory of
the computer
• LOC(LA[K]) = address of the element
LA[K] of the array LA
• The element of LA are stored in the
successive memory cells
• Computer does not need to keep track of
the address of every element of LA, but
need to track only the address of the first
element of the array denoted by Base(LA)
called the base address of LA
11
Representation of Linear Array in Memory
• LOC(LA[K]) = Base(LA) + w(K – lower
bound) where w is the number of words
per memory cell of the array LA [w is
aka size of the data type]
12
Example 1
13
200
201
202
203
204
205
206
207
LA[1]
LA[3]
LA[4]
LA[5]
LA[6]
LA[7]
LA[8]
LA[2]
Find the address for LA[6]
Each element of the array
occupy 1 byte
LOC(LA[K]) = Base(LA) + w(K – lower bound)
LOC(LA[6]) = 200 + 1(6 – 1) = 205
:
Example 2
14
200
201
202
203
204
205
206
207
LA[1]
LA[2]
LA[3]
LA[4]
Find the address for LA[16]
Each element of the array
occupy 2 byte
LOC(LA[K]) = Base(LA) + w(K – lower bound)
LOC(LA[16]) = 200 + 2(16 – 1) = 230
:
Representation of Linear Array in Memory
• Given any value of K, time to calculate
LOC(LA[K]) is same
• Given any subscript K one can access and
locate the content of LA[K] without
scanning any other element of LA
• A collection A of data element is said to be
index if any element of A called Ak can be
located and processed in time that is
independent of K
15
Traversing Linear Arrays
• Traversing is accessing and processing
(aka visiting ) each element of the data
structure exactly ones
16
•••
Linear Array
Traversing Linear Arrays
• Traversing is accessing and processing
(aka visiting ) each element of the data
structure exactly ones
17
•••
Linear Array
Traversing Linear Arrays
• Traversing is accessing and processing
(aka visiting ) each element of the data
structure exactly ones
18
•••
Linear Array
Traversing Linear Arrays
• Traversing is accessing and processing
(aka visiting ) each element of the data
structure exactly ones
19
•••
Linear Array
Traversing Linear Arrays
• Traversing is accessing and processing
(aka visiting ) each element of the data
structure exactly ones
20
•••
Linear Array
Traversing Linear Arrays
• Traversing is accessing and processing
(aka visiting ) each element of the data
structure exactly ones
21
•••
Linear Array
Traversing Linear Arrays
• Traversing is accessing and processing
(aka visiting ) each element of the data
structure exactly ones
22
•••
Linear Array
1. Repeat for K = LB to UB
Apply PROCESS to LA[K]
[End of Loop]
2. Exit
Inserting and Deleting
• Insertion: Adding an element
– Beginning
– Middle
– End
• Deletion: Removing an element
– Beginning
– Middle
– End
23
Insertion
1 Brown
2 Davis
3 Johnson
4 Smith
5 Wagner
6
7
8
24
1 Brown
2 Davis
3 Johnson
4 Smith
5 Wagner
6 Ford
7
8
Insert Ford at the End of Array
Insertion
1 Brown
2 Davis
3 Johnson
4 Smith
5 Wagner
6
7
8
25
1 Brown
2 Davis
3 Johnson
4 Smith
5
6 Wagner
7
8
Insert Ford as the 3rd Element of Array
1 Brown
2 Davis
3 Johnson
4
5 Smith
6 Wagner
7
8
1 Brown
2 Davis
3
4 Johnson
5 Smith
6 Wagner
7
8
Ford
Insertion is not Possible without loss
of data if the array is FULL
Deletion
1 Brown
2 Davis
3 Ford
4 Johnson
5 Smith
6 Taylor
7 Wagner
8
26
1 Brown
2 Davis
3 Ford
4 Johnson
5 Smith
6 Taylor
7
8
Deletion of Wagner at the End of Array
Deletion
1 Brown
2 Davis
3 Ford
4 Johnson
5 Smith
6 Taylor
7 Wagner
8
27
1 Brown
2
3 Ford
4 Johnson
5 Smith
6 Taylor
7 Wagner
8
Deletion of Davis from the Array
1 Brown
2 Ford
3
4 Johnson
5 Smith
6 Taylor
7 Wagner
8
1 Brown
2 Ford
3 Johnson
4
5 Smith
6 Taylor
7 Wagner
8
Deletion
1 Brown
2 Ford
3 Johnson
4 Smith
5 Taylor
6 Wagner
7
8
28
No data item can be deleted from an empty
array
Insertion Algorithm
• INSERT (LA, N , K , ITEM) [LA is a
linear array with N elements and K is a positive
integers such that K ≤ N. This algorithm insert an
element ITEM into the Kth position in LA ]
1. [Initialize Counter] Set J := N
2. Repeat Steps 3 and 4 while J ≥ K
3. [Move the Jth element downward ] Set LA[J + 1]
:= LA[J]
4. [Decrease Counter] Set J := J -1
5 [Insert Element] Set LA[K] := ITEM
6. [Reset N] Set N := N +1;
7. Exit
29
Deletion Algorithm
• DELETE (LA, N , K , ITEM) [LA is a
linear array with N elements and K is a positive
integers such that K ≤ N. This algorithm deletes Kth
element from LA ]
1. Set ITEM := LA[K]
2. Repeat for J = K to N -1:
[Move the J + 1st element upward] Set LA[J]
:= LA[J + 1]
3. [Reset the number N of elements] Set N := N - 1;
4. Exit
30
Multidimensional Array
• One-Dimensional Array
• Two-Dimensional Array
• Three-Dimensional Array
• Some programming Language allows as
many as 7 dimension
31
Two-Dimensional Array
• A Two-Dimensional m x n array A is a
collection of m . n data elements such
that each element is specified by a pair
of integer (such as J, K) called
subscript with property that
1 ≤ J ≤ m and 1 ≤ K ≤ n
The element of A with first subscript J
and second subscript K will be denoted
by AJ,K or A[J][K]
32
2D Arrays
The elements of a 2-dimensional array a
is shown as below
a[0][0] a[0][1] a[0][2] a[0][3]
a[1][0] a[1][1] a[1][2] a[1][3]
a[2][0] a[2][1] a[2][2] a[2][3]
Rows Of A 2D Array
a[0][0] a[0][1] a[0][2] a[0][3] row 0
a[1][0] a[1][1] a[1][2] a[1][3] row 1
a[2][0] a[2][1] a[2][2] a[2][3] row 2
Columns Of A 2D Array
a[0][0] a[0][1] a[0][2] a[0][3]
a[1][0] a[1][1] a[1][2] a[1][3]
a[2][0] a[2][1] a[2][2] a[2][3]
column 0 column 1 column 2 column 3
2D Array
• Let A be a two-dimensional array m x n
• The array A will be represented in the
memory by a block of m x n sequential
memory location
• Programming language will store array A
either
– Column by Column (Called Column-Major
Order) Ex: Fortran, MATLAB
– Row by Row (Called Row-Major Order) Ex: C,
C++ , Java
36
2D Array in Memory
A Subscript
(1,1)
(2,1)
(3,1)
(1,2)
(2,2)
(3,2)
(1,3)
(2,3)
(3,3)
(1,4)
(2,4)
(3,4)
37
Column 1
Column 2
Column 3
Column 4
A Subscript
(1,1)
(1,2)
(1,3)
(1,4)
(2,1)
(2,2)
(2,3)
(2,4)
(3,1)
(3,2)
(3,3)
(3,4)
Row 1
Row 3
Row 2
Column-Major Order Row-Major Order
2D Array
• LOC(LA[K]) = Base(LA) + w(K -1)
• LOC(A[J,K]) of A[J,K]
Column-Major Order
LOC(A[J,K]) = Base(A) + w[m(K-1) + (J-1)]
Row-Major Order
LOC(A[J,K]) = Base(A) + w[n(J-1) + (K-1)]
38
2D Array Example
• Consider a 25 x 4 array A. Suppose the
Base(A) = 200 and w =4. Suppose the
programming store 2D array using row-
major. Compute LOC(A[12,3])
• LOC(A[J,K]) = Base(A) + w[n(J-1) + (K-1)]
• LOC(A[12,3]) = 200 + 4[4(12-1) + (3 -1)]
= 384
39
Multidimensional Array
• An n-dimensional m1 x m2 x …. X mn array B
is a collection of m1.m2…mn data elements
in which each element is specified by a list
of n integers – such as K1, K2, …., Kn – called
subscript with the property that
1≤K1≤m1, 1≤K2≤m2, …. 1≤Kn≤mn
The Element B with subscript K1, K2, …,Kn will
be denoted by
BK1,K2, …,Kn or B[K1,K2,….,Kn]
40
Multidimensional Array
• Let C be a n-dimensional array
• Length Li of dimension i of C is the
number of elements in the index set
Li = UB – LB + 1
• For a given subscript Ki, the effective
index Ei of Li is the number of indices
preceding Ki in the index set
Ei = Ki – LB
41
Multidimensional Array
• Address LOC(C[K1,K2, …., Kn]) of an
arbitrary element of C can be obtained as
Column-Major Order
Base( C) + w[((( … (ENLN-1 + EN-1)LN-2)
+ ….. +E3)L2+E2)L1+E1]
Row-Major Order
Base( C) + w[(… ((E1L2 + E2)L3 + E3)L4
+ ….. +EN-1)LN +EN]
42
Example
• MAZE(2:8, -4:1, 6:10)
• Calculate the address of MAZE[5,-1,8]
• Given: Base(MAZE) = 200, w = 4, MAZE
is stored in Row-Major order
• L1 = 8-2+1 = 7, L2 = 6, L3 = 5
• E1 = 5 -2 = 3, E2 = 3, E3 = 2
43
Example Contd ..
• Base( C) + w[(… ((E1L2 + E2)L3 + E3)L4 +
….. +EN-1)LN +EN]
• E1L2 = 3 . 6 = 18
• E1L2 + E2 = 18 + 3 = 21
• (E1L2 + E2)L3 = 21 . 5 = 105
• (E1L2+E2)L3 + E3 = 105 + 2 = 107
• MAZE[5,-1,8] = 200 + 4(107) = 200 +
248 = 628
44
Pointer, Pointer Array
• Let DATA be any array
• A variable P is called a pointer if P
points to an element in DATA i.e if P
contains the address of an element in
DATA
• An array PTR is called a pointer array if
each element of PTR is a pointer
45
Group 1 Group 2 Group 3 Group 4
Evan Conrad Davis Baker
Harris Felt Segal Cooper
Lewis Glass Ford
Shaw Hill Gray
Penn Jones
Silver Reed
Troy
Wagner
King
46
Two Dimensional
4x9 or 9x4 array
1 Evan
2 Harris
3 Lewis
4 Shaw
5 Conrad
: :
13 Wagner
14 Davis
15 Segal
16 Baker
: :
21 Reed
47
Group 1
Group 2
Group 3
Group 4
1 Evan
: :
4 Shaw
5 $$$
6 Conrad
: :
14 Wagner
15 $$$
16 Davis
17 Segal
18 $$$
19 Baker
: :
24 Reed 48
Group 1
Group 2
Group 3
Group 4
Group are not index
in this
representation
1 Evan
2 Harris
3 Lewis
4 Shaw
5 Conrad
: :
13 Wagner
14 Davis
15 Segal
16 Baker
: :
21 Reed
22 $$$
49
Group 1
Group 2
Group 3
Group 4
1 1
2 5
3 14
4 16
5 22
Group

More Related Content

What's hot

What's hot (20)

Arrays In C++
Arrays In C++Arrays In C++
Arrays In C++
 
Data structure and its types
Data structure and its typesData structure and its types
Data structure and its types
 
Array
ArrayArray
Array
 
Data Structures (CS8391)
Data Structures (CS8391)Data Structures (CS8391)
Data Structures (CS8391)
 
Data structures
Data structuresData structures
Data structures
 
Data structures using C
Data structures using CData structures using C
Data structures using C
 
Data structure
Data structureData structure
Data structure
 
Array Presentation
Array PresentationArray Presentation
Array Presentation
 
Data structures using c
Data structures using cData structures using c
Data structures using c
 
2nd puc computer science chapter 3 data structures 1
2nd puc computer science chapter 3 data structures 12nd puc computer science chapter 3 data structures 1
2nd puc computer science chapter 3 data structures 1
 
Data structures
Data structuresData structures
Data structures
 
Data Structures Notes 2021
Data Structures Notes 2021Data Structures Notes 2021
Data Structures Notes 2021
 
C++ Arrays
C++ ArraysC++ Arrays
C++ Arrays
 
Data Structures (BE)
Data Structures (BE)Data Structures (BE)
Data Structures (BE)
 
Introduction to Data Structure
Introduction to Data Structure Introduction to Data Structure
Introduction to Data Structure
 
02 Arrays And Memory Mapping
02 Arrays And Memory Mapping02 Arrays And Memory Mapping
02 Arrays And Memory Mapping
 
Data Structure In C#
Data Structure In C#Data Structure In C#
Data Structure In C#
 
Arrays Basics
Arrays BasicsArrays Basics
Arrays Basics
 
Row major and column major in 2 d
Row major and column major in 2 dRow major and column major in 2 d
Row major and column major in 2 d
 
Data structures and algorithms
Data structures and algorithmsData structures and algorithms
Data structures and algorithms
 

Viewers also liked (10)

Arrays
ArraysArrays
Arrays
 
Arrays Data Structure
Arrays Data StructureArrays Data Structure
Arrays Data Structure
 
Stacks Implementation and Examples
Stacks Implementation and ExamplesStacks Implementation and Examples
Stacks Implementation and Examples
 
Stack Applications
Stack ApplicationsStack Applications
Stack Applications
 
Array Presentation (EngineerBaBu.com)
Array Presentation (EngineerBaBu.com)Array Presentation (EngineerBaBu.com)
Array Presentation (EngineerBaBu.com)
 
Stack
StackStack
Stack
 
Arrays
ArraysArrays
Arrays
 
STACKS IN DATASTRUCTURE
STACKS IN DATASTRUCTURESTACKS IN DATASTRUCTURE
STACKS IN DATASTRUCTURE
 
DATA STRUCTURES
DATA STRUCTURESDATA STRUCTURES
DATA STRUCTURES
 
Flink vs. Spark
Flink vs. SparkFlink vs. Spark
Flink vs. Spark
 

Similar to 2.DS Array

Lecture 3 data structures and algorithms
Lecture 3 data structures and algorithmsLecture 3 data structures and algorithms
Lecture 3 data structures and algorithmsAakash deep Singhal
 
2. Array in Data Structure
2. Array in Data Structure2. Array in Data Structure
2. Array in Data StructureMandeep Singh
 
BCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHI
BCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHIBCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHI
BCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHISowmya Jyothi
 
Ist year Msc,2nd sem module1
Ist year Msc,2nd sem module1Ist year Msc,2nd sem module1
Ist year Msc,2nd sem module1blessyboban92
 
data structure and algorithm Array.pptx btech 2nd year
data structure and algorithm  Array.pptx btech 2nd yeardata structure and algorithm  Array.pptx btech 2nd year
data structure and algorithm Array.pptx btech 2nd yearpalhimanshi999
 
Basic of array and data structure, data structure basics, array, address calc...
Basic of array and data structure, data structure basics, array, address calc...Basic of array and data structure, data structure basics, array, address calc...
Basic of array and data structure, data structure basics, array, address calc...nsitlokeshjain
 
Lecture 7 data structures and algorithms
Lecture 7 data structures and algorithmsLecture 7 data structures and algorithms
Lecture 7 data structures and algorithmsAakash deep Singhal
 
PPT Lecture 2.2.1 onn c++ data structures
PPT Lecture 2.2.1 onn c++ data structuresPPT Lecture 2.2.1 onn c++ data structures
PPT Lecture 2.2.1 onn c++ data structuresmidtushar
 
COMPUTER PROGRAMMING UNIT 1 Lecture 5
COMPUTER PROGRAMMING UNIT 1 Lecture 5COMPUTER PROGRAMMING UNIT 1 Lecture 5
COMPUTER PROGRAMMING UNIT 1 Lecture 5Vishal Patil
 
Two Dimensional Array
Two Dimensional ArrayTwo Dimensional Array
Two Dimensional Arraydincyjain
 
Data structure using c module 1
Data structure using c module 1Data structure using c module 1
Data structure using c module 1smruti sarangi
 
data structure unit -1_170434dd7400.pptx
data structure unit -1_170434dd7400.pptxdata structure unit -1_170434dd7400.pptx
data structure unit -1_170434dd7400.pptxcoc7987515756
 
Array 2
Array 2Array 2
Array 2Abbott
 

Similar to 2.DS Array (20)

Arrays
ArraysArrays
Arrays
 
Lecture 3 data structures and algorithms
Lecture 3 data structures and algorithmsLecture 3 data structures and algorithms
Lecture 3 data structures and algorithms
 
arrays in data structure.pptx
arrays in data structure.pptxarrays in data structure.pptx
arrays in data structure.pptx
 
2. Array in Data Structure
2. Array in Data Structure2. Array in Data Structure
2. Array in Data Structure
 
BCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHI
BCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHIBCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHI
BCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHI
 
cluod.pdf
cluod.pdfcluod.pdf
cluod.pdf
 
Ist year Msc,2nd sem module1
Ist year Msc,2nd sem module1Ist year Msc,2nd sem module1
Ist year Msc,2nd sem module1
 
data structure and algorithm Array.pptx btech 2nd year
data structure and algorithm  Array.pptx btech 2nd yeardata structure and algorithm  Array.pptx btech 2nd year
data structure and algorithm Array.pptx btech 2nd year
 
Arrays.pptx
Arrays.pptxArrays.pptx
Arrays.pptx
 
Basic of array and data structure, data structure basics, array, address calc...
Basic of array and data structure, data structure basics, array, address calc...Basic of array and data structure, data structure basics, array, address calc...
Basic of array and data structure, data structure basics, array, address calc...
 
Lecture 7 data structures and algorithms
Lecture 7 data structures and algorithmsLecture 7 data structures and algorithms
Lecture 7 data structures and algorithms
 
6.queue
6.queue6.queue
6.queue
 
PPT Lecture 2.2.1 onn c++ data structures
PPT Lecture 2.2.1 onn c++ data structuresPPT Lecture 2.2.1 onn c++ data structures
PPT Lecture 2.2.1 onn c++ data structures
 
COMPUTER PROGRAMMING UNIT 1 Lecture 5
COMPUTER PROGRAMMING UNIT 1 Lecture 5COMPUTER PROGRAMMING UNIT 1 Lecture 5
COMPUTER PROGRAMMING UNIT 1 Lecture 5
 
Two Dimensional Array
Two Dimensional ArrayTwo Dimensional Array
Two Dimensional Array
 
Data structure using c module 1
Data structure using c module 1Data structure using c module 1
Data structure using c module 1
 
data structure unit -1_170434dd7400.pptx
data structure unit -1_170434dd7400.pptxdata structure unit -1_170434dd7400.pptx
data structure unit -1_170434dd7400.pptx
 
Array 2
Array 2Array 2
Array 2
 
DSA.pdf
DSA.pdfDSA.pdf
DSA.pdf
 
Arrays in C.pptx
Arrays in C.pptxArrays in C.pptx
Arrays in C.pptx
 

More from Chandan Singh

Fundamental of Tissue engineering
Fundamental of Tissue engineeringFundamental of Tissue engineering
Fundamental of Tissue engineeringChandan Singh
 
Resistance Measurement instruments
Resistance Measurement instrumentsResistance Measurement instruments
Resistance Measurement instrumentsChandan Singh
 
Resistance Measurement instruments
Resistance Measurement instrumentsResistance Measurement instruments
Resistance Measurement instrumentsChandan Singh
 
Moving iron (MI) instruments
Moving iron (MI) instrumentsMoving iron (MI) instruments
Moving iron (MI) instrumentsChandan Singh
 
Moving iron (MI) instruments
Moving iron (MI) instrumentsMoving iron (MI) instruments
Moving iron (MI) instrumentsChandan Singh
 
Electrical Measurement & Instruments
Electrical Measurement & InstrumentsElectrical Measurement & Instruments
Electrical Measurement & InstrumentsChandan Singh
 
Static characteristics of Instruments
Static characteristics of InstrumentsStatic characteristics of Instruments
Static characteristics of InstrumentsChandan Singh
 
Resistance measurement
Resistance measurementResistance measurement
Resistance measurementChandan Singh
 
Introduction to sensors
Introduction to sensorsIntroduction to sensors
Introduction to sensorsChandan Singh
 
Classification (Analog instruments)
 Classification (Analog instruments) Classification (Analog instruments)
Classification (Analog instruments)Chandan Singh
 
AC Bridges: Balance Condition
AC Bridges: Balance ConditionAC Bridges: Balance Condition
AC Bridges: Balance ConditionChandan Singh
 
Cathode Ray Osciloscope
Cathode Ray OsciloscopeCathode Ray Osciloscope
Cathode Ray OsciloscopeChandan Singh
 
Instrument transformer CT & PT
Instrument transformer CT & PTInstrument transformer CT & PT
Instrument transformer CT & PTChandan Singh
 
Permanent Magnet Moving Coil
Permanent Magnet Moving Coil Permanent Magnet Moving Coil
Permanent Magnet Moving Coil Chandan Singh
 
10.m way search tree
10.m way search tree10.m way search tree
10.m way search treeChandan Singh
 
9.bst(contd.) avl tree
9.bst(contd.) avl tree9.bst(contd.) avl tree
9.bst(contd.) avl treeChandan Singh
 

More from Chandan Singh (20)

Fundamental of Tissue engineering
Fundamental of Tissue engineeringFundamental of Tissue engineering
Fundamental of Tissue engineering
 
Resistance Measurement instruments
Resistance Measurement instrumentsResistance Measurement instruments
Resistance Measurement instruments
 
Resistance Measurement instruments
Resistance Measurement instrumentsResistance Measurement instruments
Resistance Measurement instruments
 
Moving iron (MI) instruments
Moving iron (MI) instrumentsMoving iron (MI) instruments
Moving iron (MI) instruments
 
Moving iron (MI) instruments
Moving iron (MI) instrumentsMoving iron (MI) instruments
Moving iron (MI) instruments
 
Electrical Measurement & Instruments
Electrical Measurement & InstrumentsElectrical Measurement & Instruments
Electrical Measurement & Instruments
 
Static characteristics of Instruments
Static characteristics of InstrumentsStatic characteristics of Instruments
Static characteristics of Instruments
 
Resistance measurement
Resistance measurementResistance measurement
Resistance measurement
 
Introduction to sensors
Introduction to sensorsIntroduction to sensors
Introduction to sensors
 
Energy meter
Energy meterEnergy meter
Energy meter
 
Classification (Analog instruments)
 Classification (Analog instruments) Classification (Analog instruments)
Classification (Analog instruments)
 
AC Bridges: Balance Condition
AC Bridges: Balance ConditionAC Bridges: Balance Condition
AC Bridges: Balance Condition
 
Cathode Ray Osciloscope
Cathode Ray OsciloscopeCathode Ray Osciloscope
Cathode Ray Osciloscope
 
Instrument transformer CT & PT
Instrument transformer CT & PTInstrument transformer CT & PT
Instrument transformer CT & PT
 
Megohmmeter
MegohmmeterMegohmmeter
Megohmmeter
 
Moving Iron
Moving IronMoving Iron
Moving Iron
 
Permanent Magnet Moving Coil
Permanent Magnet Moving Coil Permanent Magnet Moving Coil
Permanent Magnet Moving Coil
 
10.m way search tree
10.m way search tree10.m way search tree
10.m way search tree
 
9.bst(contd.) avl tree
9.bst(contd.) avl tree9.bst(contd.) avl tree
9.bst(contd.) avl tree
 
8.binry search tree
8.binry search tree8.binry search tree
8.binry search tree
 

Recently uploaded

Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).pptssuser5c9d4b1
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 

Recently uploaded (20)

Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 

2.DS Array

  • 1. Data Structure and Algorithm CS-102 Ashok K Turuk 1
  • 2. Data Structure vs Storage Structure • Data Structure : The logical or mathematical model of a particular organization of data • Storage Structure : Representation of a particular data structure in the memory of a computer • There are many possible storage structure to a particular data structure • Ex: there are a number of storage structure for a data structure such as array – It is possible for two DS to represented by the same storage structure 2
  • 3. Classification • Data Structure – Linear – Non-Linear • A Data structure is said to be linear if its elements from a sequence or in other words form a linear list 3
  • 4. Representation in Memory • Two basic representation in memory – Have a linear relationship between the elements represented by means of sequential memory locations [ Arrays] – Have the linear relationship between the elements represented by means of pointer or links [ Linked List] 4
  • 5. Operation on Linear Structure • Traversal : Processing each element in the list • Search : Finding the location of the element with a given value or the record with a given key • Insertion: Adding a new element to the list • Deletion: Removing an elements from the list • Sorting : Arranging the elements in some type of order • Merging : Combining two list into a single list 5
  • 7. Linear Arrays • A linear array is a list of a finite number of n homogeneous data elements ( that is data elements of the same type) such that – The elements are of the arrays are referenced respectively by an index set consisting of n consecutive numbers – The elements of the arrays are stored respectively in successive memory locations 7
  • 8. Linear Arrays • The number n of elements is called the length or size of the array. • The index set consists of the integer 1, 2, … n • Length or the number of data elements of the array can be obtained from the index set by Length = UB – LB + 1 where UB is the largest index called the upper bound and LB is the smallest index called the lower bound of the arrays 8
  • 9. Linear Arrays • Element of an array A may be denoted by – Subscript notation A1, A2, , …. , An – Parenthesis notation A(1), A(2), …. , A(n) – Bracket notation A[1], A[2], ….. , A[n] • The number K in A[K] is called subscript or an index and A[K] is called a subscripted variable 9
  • 10. Representation of Linear Array in Memory 10 1000 1001 1002 1003 1004 1005 Computer Memory :
  • 11. Representation of Linear Array in Memory • Let LA be a linear array in the memory of the computer • LOC(LA[K]) = address of the element LA[K] of the array LA • The element of LA are stored in the successive memory cells • Computer does not need to keep track of the address of every element of LA, but need to track only the address of the first element of the array denoted by Base(LA) called the base address of LA 11
  • 12. Representation of Linear Array in Memory • LOC(LA[K]) = Base(LA) + w(K – lower bound) where w is the number of words per memory cell of the array LA [w is aka size of the data type] 12
  • 13. Example 1 13 200 201 202 203 204 205 206 207 LA[1] LA[3] LA[4] LA[5] LA[6] LA[7] LA[8] LA[2] Find the address for LA[6] Each element of the array occupy 1 byte LOC(LA[K]) = Base(LA) + w(K – lower bound) LOC(LA[6]) = 200 + 1(6 – 1) = 205 :
  • 14. Example 2 14 200 201 202 203 204 205 206 207 LA[1] LA[2] LA[3] LA[4] Find the address for LA[16] Each element of the array occupy 2 byte LOC(LA[K]) = Base(LA) + w(K – lower bound) LOC(LA[16]) = 200 + 2(16 – 1) = 230 :
  • 15. Representation of Linear Array in Memory • Given any value of K, time to calculate LOC(LA[K]) is same • Given any subscript K one can access and locate the content of LA[K] without scanning any other element of LA • A collection A of data element is said to be index if any element of A called Ak can be located and processed in time that is independent of K 15
  • 16. Traversing Linear Arrays • Traversing is accessing and processing (aka visiting ) each element of the data structure exactly ones 16 ••• Linear Array
  • 17. Traversing Linear Arrays • Traversing is accessing and processing (aka visiting ) each element of the data structure exactly ones 17 ••• Linear Array
  • 18. Traversing Linear Arrays • Traversing is accessing and processing (aka visiting ) each element of the data structure exactly ones 18 ••• Linear Array
  • 19. Traversing Linear Arrays • Traversing is accessing and processing (aka visiting ) each element of the data structure exactly ones 19 ••• Linear Array
  • 20. Traversing Linear Arrays • Traversing is accessing and processing (aka visiting ) each element of the data structure exactly ones 20 ••• Linear Array
  • 21. Traversing Linear Arrays • Traversing is accessing and processing (aka visiting ) each element of the data structure exactly ones 21 ••• Linear Array
  • 22. Traversing Linear Arrays • Traversing is accessing and processing (aka visiting ) each element of the data structure exactly ones 22 ••• Linear Array 1. Repeat for K = LB to UB Apply PROCESS to LA[K] [End of Loop] 2. Exit
  • 23. Inserting and Deleting • Insertion: Adding an element – Beginning – Middle – End • Deletion: Removing an element – Beginning – Middle – End 23
  • 24. Insertion 1 Brown 2 Davis 3 Johnson 4 Smith 5 Wagner 6 7 8 24 1 Brown 2 Davis 3 Johnson 4 Smith 5 Wagner 6 Ford 7 8 Insert Ford at the End of Array
  • 25. Insertion 1 Brown 2 Davis 3 Johnson 4 Smith 5 Wagner 6 7 8 25 1 Brown 2 Davis 3 Johnson 4 Smith 5 6 Wagner 7 8 Insert Ford as the 3rd Element of Array 1 Brown 2 Davis 3 Johnson 4 5 Smith 6 Wagner 7 8 1 Brown 2 Davis 3 4 Johnson 5 Smith 6 Wagner 7 8 Ford Insertion is not Possible without loss of data if the array is FULL
  • 26. Deletion 1 Brown 2 Davis 3 Ford 4 Johnson 5 Smith 6 Taylor 7 Wagner 8 26 1 Brown 2 Davis 3 Ford 4 Johnson 5 Smith 6 Taylor 7 8 Deletion of Wagner at the End of Array
  • 27. Deletion 1 Brown 2 Davis 3 Ford 4 Johnson 5 Smith 6 Taylor 7 Wagner 8 27 1 Brown 2 3 Ford 4 Johnson 5 Smith 6 Taylor 7 Wagner 8 Deletion of Davis from the Array 1 Brown 2 Ford 3 4 Johnson 5 Smith 6 Taylor 7 Wagner 8 1 Brown 2 Ford 3 Johnson 4 5 Smith 6 Taylor 7 Wagner 8
  • 28. Deletion 1 Brown 2 Ford 3 Johnson 4 Smith 5 Taylor 6 Wagner 7 8 28 No data item can be deleted from an empty array
  • 29. Insertion Algorithm • INSERT (LA, N , K , ITEM) [LA is a linear array with N elements and K is a positive integers such that K ≤ N. This algorithm insert an element ITEM into the Kth position in LA ] 1. [Initialize Counter] Set J := N 2. Repeat Steps 3 and 4 while J ≥ K 3. [Move the Jth element downward ] Set LA[J + 1] := LA[J] 4. [Decrease Counter] Set J := J -1 5 [Insert Element] Set LA[K] := ITEM 6. [Reset N] Set N := N +1; 7. Exit 29
  • 30. Deletion Algorithm • DELETE (LA, N , K , ITEM) [LA is a linear array with N elements and K is a positive integers such that K ≤ N. This algorithm deletes Kth element from LA ] 1. Set ITEM := LA[K] 2. Repeat for J = K to N -1: [Move the J + 1st element upward] Set LA[J] := LA[J + 1] 3. [Reset the number N of elements] Set N := N - 1; 4. Exit 30
  • 31. Multidimensional Array • One-Dimensional Array • Two-Dimensional Array • Three-Dimensional Array • Some programming Language allows as many as 7 dimension 31
  • 32. Two-Dimensional Array • A Two-Dimensional m x n array A is a collection of m . n data elements such that each element is specified by a pair of integer (such as J, K) called subscript with property that 1 ≤ J ≤ m and 1 ≤ K ≤ n The element of A with first subscript J and second subscript K will be denoted by AJ,K or A[J][K] 32
  • 33. 2D Arrays The elements of a 2-dimensional array a is shown as below a[0][0] a[0][1] a[0][2] a[0][3] a[1][0] a[1][1] a[1][2] a[1][3] a[2][0] a[2][1] a[2][2] a[2][3]
  • 34. Rows Of A 2D Array a[0][0] a[0][1] a[0][2] a[0][3] row 0 a[1][0] a[1][1] a[1][2] a[1][3] row 1 a[2][0] a[2][1] a[2][2] a[2][3] row 2
  • 35. Columns Of A 2D Array a[0][0] a[0][1] a[0][2] a[0][3] a[1][0] a[1][1] a[1][2] a[1][3] a[2][0] a[2][1] a[2][2] a[2][3] column 0 column 1 column 2 column 3
  • 36. 2D Array • Let A be a two-dimensional array m x n • The array A will be represented in the memory by a block of m x n sequential memory location • Programming language will store array A either – Column by Column (Called Column-Major Order) Ex: Fortran, MATLAB – Row by Row (Called Row-Major Order) Ex: C, C++ , Java 36
  • 37. 2D Array in Memory A Subscript (1,1) (2,1) (3,1) (1,2) (2,2) (3,2) (1,3) (2,3) (3,3) (1,4) (2,4) (3,4) 37 Column 1 Column 2 Column 3 Column 4 A Subscript (1,1) (1,2) (1,3) (1,4) (2,1) (2,2) (2,3) (2,4) (3,1) (3,2) (3,3) (3,4) Row 1 Row 3 Row 2 Column-Major Order Row-Major Order
  • 38. 2D Array • LOC(LA[K]) = Base(LA) + w(K -1) • LOC(A[J,K]) of A[J,K] Column-Major Order LOC(A[J,K]) = Base(A) + w[m(K-1) + (J-1)] Row-Major Order LOC(A[J,K]) = Base(A) + w[n(J-1) + (K-1)] 38
  • 39. 2D Array Example • Consider a 25 x 4 array A. Suppose the Base(A) = 200 and w =4. Suppose the programming store 2D array using row- major. Compute LOC(A[12,3]) • LOC(A[J,K]) = Base(A) + w[n(J-1) + (K-1)] • LOC(A[12,3]) = 200 + 4[4(12-1) + (3 -1)] = 384 39
  • 40. Multidimensional Array • An n-dimensional m1 x m2 x …. X mn array B is a collection of m1.m2…mn data elements in which each element is specified by a list of n integers – such as K1, K2, …., Kn – called subscript with the property that 1≤K1≤m1, 1≤K2≤m2, …. 1≤Kn≤mn The Element B with subscript K1, K2, …,Kn will be denoted by BK1,K2, …,Kn or B[K1,K2,….,Kn] 40
  • 41. Multidimensional Array • Let C be a n-dimensional array • Length Li of dimension i of C is the number of elements in the index set Li = UB – LB + 1 • For a given subscript Ki, the effective index Ei of Li is the number of indices preceding Ki in the index set Ei = Ki – LB 41
  • 42. Multidimensional Array • Address LOC(C[K1,K2, …., Kn]) of an arbitrary element of C can be obtained as Column-Major Order Base( C) + w[((( … (ENLN-1 + EN-1)LN-2) + ….. +E3)L2+E2)L1+E1] Row-Major Order Base( C) + w[(… ((E1L2 + E2)L3 + E3)L4 + ….. +EN-1)LN +EN] 42
  • 43. Example • MAZE(2:8, -4:1, 6:10) • Calculate the address of MAZE[5,-1,8] • Given: Base(MAZE) = 200, w = 4, MAZE is stored in Row-Major order • L1 = 8-2+1 = 7, L2 = 6, L3 = 5 • E1 = 5 -2 = 3, E2 = 3, E3 = 2 43
  • 44. Example Contd .. • Base( C) + w[(… ((E1L2 + E2)L3 + E3)L4 + ….. +EN-1)LN +EN] • E1L2 = 3 . 6 = 18 • E1L2 + E2 = 18 + 3 = 21 • (E1L2 + E2)L3 = 21 . 5 = 105 • (E1L2+E2)L3 + E3 = 105 + 2 = 107 • MAZE[5,-1,8] = 200 + 4(107) = 200 + 248 = 628 44
  • 45. Pointer, Pointer Array • Let DATA be any array • A variable P is called a pointer if P points to an element in DATA i.e if P contains the address of an element in DATA • An array PTR is called a pointer array if each element of PTR is a pointer 45
  • 46. Group 1 Group 2 Group 3 Group 4 Evan Conrad Davis Baker Harris Felt Segal Cooper Lewis Glass Ford Shaw Hill Gray Penn Jones Silver Reed Troy Wagner King 46 Two Dimensional 4x9 or 9x4 array
  • 47. 1 Evan 2 Harris 3 Lewis 4 Shaw 5 Conrad : : 13 Wagner 14 Davis 15 Segal 16 Baker : : 21 Reed 47 Group 1 Group 2 Group 3 Group 4
  • 48. 1 Evan : : 4 Shaw 5 $$$ 6 Conrad : : 14 Wagner 15 $$$ 16 Davis 17 Segal 18 $$$ 19 Baker : : 24 Reed 48 Group 1 Group 2 Group 3 Group 4 Group are not index in this representation
  • 49. 1 Evan 2 Harris 3 Lewis 4 Shaw 5 Conrad : : 13 Wagner 14 Davis 15 Segal 16 Baker : : 21 Reed 22 $$$ 49 Group 1 Group 2 Group 3 Group 4 1 1 2 5 3 14 4 16 5 22 Group