LINEAR ARRAYS IN PROGRAMMING
LINEAR ARRAY A linear array is a list that contains a group of elements. Typically, these elements are all Finite number and the same data type. Few points about Linear Array: • The number of element is called sizes/length of array • The elements are stored respectively in successive memory locations. • Computer does not check every element of array but only first element. Which is base address of array.
ARRAY’S LENGTH = UB-LB+1 Example : A(50,5) So, the length is =(50-5+1) =46 Where UB=Upper Bound and LB=Lower Bound Arrays element may be denoted by 3way’s- 1. Subscript notation: A1,A2,A3…………………………………….An 2. Bracket notation: A[1],A[2],A[3]…………………………………….A[n] 3. Parenthesis Notation: A(1),A(2),A(3)…………………………………….A(n)
BENEFITS: • It is used to represent multiple data items of same type by using only single name. • It can be used to implement other data structures like linked lists, stacks, queues, trees, graphs etc. • 2D arrays are used to represent matrices.
DRAWBACKS: • We must know in advance that how many elements are to be stored in array. • Array is static structure. It means that array is of fixed size. The memory which is allocated to array can not be increased or reduced. • The elements of array are stored in consecutive memory locations. So insertions and deletions are very difficult and time consuming.
REPRESENTATION OF LINEAR ARRAYS IN MEMORY: Let LA be a linear array in the memory of the computer. the computer calculates the address of any elements of LA by the following formula: LOC (LA [K]) = Base (LA) + W (K-lower bound) Where LOC (LA [K]) = address of the element LA [K] of the array LA, w is the number of words per memory cell for the array LA.
Linear Arrays in Programming: Array Length, Benefits, Drawbacks, and Memory Layout Explained

Linear Arrays in Programming: Array Length, Benefits, Drawbacks, and Memory Layout Explained

  • 1.
  • 2.
    LINEAR ARRAY A lineararray is a list that contains a group of elements. Typically, these elements are all Finite number and the same data type. Few points about Linear Array: • The number of element is called sizes/length of array • The elements are stored respectively in successive memory locations. • Computer does not check every element of array but only first element. Which is base address of array.
  • 3.
    ARRAY’S LENGTH =UB-LB+1 Example : A(50,5) So, the length is =(50-5+1) =46 Where UB=Upper Bound and LB=Lower Bound Arrays element may be denoted by 3way’s- 1. Subscript notation: A1,A2,A3…………………………………….An 2. Bracket notation: A[1],A[2],A[3]…………………………………….A[n] 3. Parenthesis Notation: A(1),A(2),A(3)…………………………………….A(n)
  • 4.
    BENEFITS: • It isused to represent multiple data items of same type by using only single name. • It can be used to implement other data structures like linked lists, stacks, queues, trees, graphs etc. • 2D arrays are used to represent matrices.
  • 5.
    DRAWBACKS: • We mustknow in advance that how many elements are to be stored in array. • Array is static structure. It means that array is of fixed size. The memory which is allocated to array can not be increased or reduced. • The elements of array are stored in consecutive memory locations. So insertions and deletions are very difficult and time consuming.
  • 6.
    REPRESENTATION OF LINEARARRAYS IN MEMORY: Let LA be a linear array in the memory of the computer. the computer calculates the address of any elements of LA by the following formula: LOC (LA [K]) = Base (LA) + W (K-lower bound) Where LOC (LA [K]) = address of the element LA [K] of the array LA, w is the number of words per memory cell for the array LA.