Array Data Structure

Types of Array Data Structure

Types of Array Data Structure

Array Data Structure is the following article of Introduction to Data Structure in Learning Data Structure Series.

Array is a collection of elements of same type, stored in sequential memory locations. The elements of array are referenced by the index or subscript of array. Array is a linear type of data structure because the memory locations are sequentially allocated to store the data.

Example: Suppose there is an array – Data – having capacity to store 10 elements then the elements of array will be referred by the index like Data[2] (read as Data of 2), Data[7] etc.

Name of Array: Data

Index 0 1 2 3 4 5 6 7 8 9
Value 10 15 35 60 45 9 12 80 33

 

eg: Data[1] = 15

Index 0 1 2 3 4 5 6 7 8 9
Value 10 15 2 35 60 45 9 12 80 33

 

eg: Data[6] = 9

Index 0 1 2 3 4 5 6 7 8 9
Value 10 15 2 35 60 45 9 12 80 33

 

There are some types of arrays like one-dimension, two-dimension and multi-dimensional array. Let’s learn it one by one.

One – Dimensional Array Data Structure:

A linear array with single subscript is known as one-dimensional array. Each element in the array is referenced by a single index or subscript. One-dimensional arrays are frequently used in programming.

Name of Array: DATA

Index 1 2 3 4 5 6
Value 27 14 85 99 101 950

 

Above example is of one-dimensional array because every element in the array is denoted by single memory location.

Example: Element 99 here is denoted as DATA[4] and 27 by DATA[1].

DATA[4] = 99

DATA[1] = 27.

Two – Dimensional Array Data Structure:

An array with two subscripts is known as two-dimensional array. A two dimensional array A is a collection of m*n data elements such that each element is specified by a pair of subscript. The two-dimensional arrays are called as matrices in mathematics and table in business applications.

Example:

Two Dimensional Array - Format

Two Dimensional Array – Format

In above array, there are two index values: Row index value and column index value. Row is horizontal element and column is vertical element.Fig: Two-dimensional 3*3 array A.

In this ,

A[1,1] means element of array A of 1st row and 1st column

A[3,2] means element of array A of  3rd  row and 2nd column

Two Dimensional Array

Two Dimensional Array

In above example A[3,2] =2

A[2,2] = 25 and

A[1,3] = 7

Multi – Dimensional Array Data Structure:

An array having more than two subscripts is known as multi-dimensional array. An n- dimensional array B is a collection of m­­1. m2. m3­…­­­. m­n ­data elements in which each element is specified by a list of n integers such as K1, K2, . , . , . ,Kn  called subscripts, with the property that

1 ≤ K1    m1    ,  1 ≤ K2   m2  ,  . . .  , 1 ≤ K   m

The elements of B with subscript K1, K2, . , . , . ,Kn  will be denoted by B[K1, K2, . , . , . ,Kn]

Multi Dimensional Array

Multi Dimensional Array

In this article we learnt basics about array data structure and their types. This article follows with the operations like insert & delete elements, sorting, searching and other operations we can perform on arrays. We will learn Insert and Delete Operation on Array in the following article of Learning Data Structure Series.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *