Array In Data Structure

Array: A set of pair (a value and a index)For each index there is a value associated with that index.

Array is represented in memory as consective memory blocks.

OR

  • An Array can be defined as an infinite collection of homogenous (simlar type)Elements.
  • Array are always stored in consecutive (specific)Memory Location.
  • Array can be store multiple values which can be referenced by a single name.

 

 

 

 

 

 

 

 

 

 

 

                           arr (0)        (1)          (2)          (3)         (4)         (5)         (6)          (7)         (8)         (9)

Implementation Of Array:

arr[0]=base address (Random address assigned to arr)

arr[k]=base address + k size of(int)


Types Of Array

  • Single Dimensional Arrays
  • Multi Dimensional Arrays
1).Singal Dimensional Arrays:-*It's also known as one Dimensional (10)Array.

*It's use only one subscript to define the elements of Arrays.

Declaration

Data-type var-name[expression]

Example-

int num[10];

char c [5];

Initializing One-Dimensional Arrays-

Data-type var-name [expression={values};

Example-

int num[10]={1,2,3,4,5,6,7,8,9,10};

char a [5]={'A','B','C','D','E'};


Comments

Popular posts from this blog

What Is Data Structure.Why Data Structure.And Types Of Data Structure?.

"Basic Introduction Of Programming Language:"

HTML(Hyper Text Markup Language)