February 20, 2018

Data Structures - Introduction to Array

What is Array:
  • Array is a linear data structure.
  • If we need to create multiple variables of similar data type, we use array.
For example if we write a statement like :  
int x[5];
This will create 5 variables named x[0],x[1],x[2],x[3],x[4] of type int.

  • They are stored in contiguous memory location.
Let 2000 be the base address of the array and each member or variable is of size 2 bytes, then each member will be allotted consecutive memory locations. This helps in ease of access of each member if we know the starting address.

Types of array:
  1. One-Dimensional (1-D) Array
  2. Two-Dimensional (2-D) Array
  3. Multi-Dimensional Array
We will discuss each type in separate posts.