Lec 2-Arrays and String Processing
Lec 2-Arrays and String Processing
Tazeen Muzammil
MSSE
Physical Memory
• Address → contents
Physical Memory
Arrays
• The array is the most commonly used data storage
structure; its built into most programming languages.
• Since arrays are usually easy to traverse, search and sort,
they are frequently used to store relatively permanent
collection of data.
• But if the size of the structure and the data in the structure
is constantly changing the array may not be useful.
• The elements of the array may be denoted by the bracket
notation
A[1], A[2], A[3]…….A[n]
Linear Array
• A linear array is a list of finite number n of
homogeneous data elements such that:
– The elements of the array are referenced
respectively by an index set consisting of n
consecutive numbers.
– The elements of the array are sorted respectively
in successive memory location.
The number n of elements is called the length or
size of the array.
Length of the Array
• The length or the number of data elements of
the array can be obtained by this formula:
Length= UB-LB+1
where:
UB is the largest index, called the upper bound
LB is the smallest index, called the lower bound
Representation of Linear Arrays in Memory