Calculating the address of any element In the 1-D array

A 1-dimensional array (or single-dimension array) is a type of linear array. Accessing its elements involves a single subscript that can either represent a row or column index. 

Example:

1D array

To find the address of an element in an array the following formula is used:

Address of A[I] = B + W * (I – LB)

I = Subset of element whose address to be found, 
B = Base address, 
W = Storage size of one element store in any array(in byte), 
LB = Lower Limit/Lower Bound of subscript(If not specified assume zero).

Example: Given the base address of an array A[1300 ………… 1900] as 1020 and the size of each element is 2 bytes in the memory, find the address of A[1700]. 

Solution:

Given:
Base address B = 1020
Lower Limit/Lower Bound of subscript LB = 1300
Storage size of one element store in any array W = 2 Byte
Subset of element whose address to be found I = 1700

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

Array Notes for GATE Exam [2024]

Arrays are fundamental data structures in computer science, and mastering them is crucial for success in the GATE exam. This article aims to provide concise yet comprehensive notes on arrays, covering essential concepts and strategies to help you tackle array-related questions in the GATE 2024 exam.

Table of Content

  • Introduction to Arrays
  • Basic terminologies of the array
  • Representation of Array
  • Types of arrays
  • Finding Adress of an Element in Array
  • Calculating the address of any element In the 1-D array
  • Calculate the address of any element in the 2-D array
  • Calculate the address of any element in the 3-D Array
  • Previously Asked GATE Questions on Arrays

Similar Reads

Introduction to Arrays:

An array is a collection of items of the same variable type that are stored at contiguous memory locations. It’s one of the most popular and simple data structures and is often used to implement other data structures. Each item in an array is indexed starting with 0....

Basic terminologies of the array:

Array Index: In an array, elements are identified by their indexes. Array index starts from 0. Array element: Elements are items stored in an array and can be accessed by their index. Array Length: The length of an array is determined by the number of elements it can contain....

Representation of Array:

The representation of an array can be defined by its declaration. A declaration means allocating memory for an array of a given size....

Types of arrays:

...

Finding Adress of an Element in Array

...

Calculating the address of any element In the 1-D array:

...

Calculate the address of any element in the 2-D array:

...

Calculate the address of any element in the 3-D Array:

...

Previously Asked GATE Questions on Arrays:

...