chap1
chap1
Chapter 01:
Introduction to Data Structure
& Algorithm
BASIC TERMINOLOGY: ELEMENTARY DATA ORGANIZATION
Formula used:
Address of A[I] = B + W * (I – LB)
Solution:
Address of A[1700] = 1020 + 2 * (1700 – 1300)
= 1020 + 2 * (400)
= 1020 + 800
Address of A[1700] = 1820
Two-Dimensional Arrays (MATRIX)
• The simplest form of the multidimensional array
is the two-dimensional array. A two- dimensional
array is, in essence, a list of one-dimensional
arrays. To declare a two-dimensional integer
array of size x,y you would write something as
follows:
Example
• A 2-dimensional array a, which contains three rows and four
columns can be shown as below:
For example:
Given an array [1…6,1…8] of integers. Calculate
address element T[5,7], where BA=300
Sol) I = 5 , J = 7
M= 6 , N= 8
Location (T [4,6]) = BA + (6 x (7-1)) + (5-1)
= 300+ (6 x 6) +4
300+ 36+4
Representation of Three& Four Dimensional Array