Lecture 1.2.1
Lecture 1.2.1
ENGINEERING
DEPARTMENT OF COMPUTER
SCIENCE AND ENGG.
Bachelor of Engineering (Computer Science & Engineering)
DATA STRUCTURES 21CSH-211
• Easy to traverse
• Easy to search & sort
• Used to store relatively permanent collections of data.
• Types of arrays:-
• Linear arrays
• Two dimensional arrays
• Multidimensional arrays
Representation of Linear array
• LOC(LA[K]) = address of the element LA[K] of the array LA
• LOC(LA[K])=Base(LA)+w(K-lower bound)
• where w is the number of words per memory cell for the array
LA.
6/27/2020
Representation of Array in a Memory
The process to determine the address in a memory:
a) First address – base address.
b) Relative address to base address through index function.
Example: char X[100];
Let char uses 1 location storage.If the base address is 1200 then the next
element is in 1201.Index Function is written as:
Loc (X[i]) = Loc(X[0]) + i , i is subscript and LB = 0
single name.
6/27/2020
Formula to calculate the Two-D Arrays
• Length = UB – LB +1
If integer NUM (2:5, -3:1), then find the length of 1st & 2nd dimensions.
Length of 1st dimension = 5 – 2 + 1 = 4
Length of 1st dimension = 1 – (-3) + 1 = 5
Number contains 4 * 5 = 20 elements.
Representation of 2-D Arrays
• Li = UB – LB + 1
• Lipschutz, Seymour, “Data Structures”, Schaum's Outline Series, Tata McGraw Hill.
• Goodrich, Michael T., Tamassia, Roberto, and Mount, David M., “Data Structures and Algorithms in C++”, Wiley
Student Edition.
• Gilberg/Forouzan,” Data Structure with C ,Cengage Learning.
• Augenstein,Moshe J , Tanenbaum, Aaron M, “Data Structures using C and C++”, Prentice Hall of India
• https://www.tutorialspoint.com/data_structures_algorithms/algorithms_basics.htm
• https://www.cs.utexas.edu/users/djimenez/utsa/cs1723/lecturehtml
6/27/2020