Posts

Types of arrays

2 min read

 

Types of arrays

  • One-dimensional Array
  • Two-dimensional Array
  • Three-dimensional Array

Two dimensional and three dimensional arrays are also called multi-dimensional arrays. in types of arrays, multi-dimensional arrays also include arrays with four and higher dimensions.

One-dimensional Array

In a one-dimensional array the elements are stored in contiguous memory locations where each element is accessed by using a single index value. It is a linear data structure storing all the elements in sequence.

Types of arrays -One dimensional array

The elements are stored in memory in continuation and the variable declared as an array is actually a pointer to the address of first element of the array. This address is called the base address. The address of any other element can be calculated with the following formula

Two-dimensional Array

In types of arrays, a two dimensional array is a tabular representation of data where elements are stored in rows and columns. A two dimensional array is actually a collection of M X N elements which has M rows and N columns.  To access any element in a two-dimensional array two subscripts are required for defining position of an element in a specific row and column. The first index is for row number and second is for column index.  In the example shown the first index values row=2 column=3 is used to access element 56.

Types of arrays -Two dimensional array

Two dimensional arrays are stored in memory in two representations

Three-dimensional Array

In types of arrays, a three-dimensional array is an extension to the two dimensional array with addition of depth. It can be seen as a cube that has rows, columns and depth as third dimension. To access any element in a three-dimensional array three subscripts are required for position of element in a specific row, column and depth. The first index is for depth (dimension or layer), second is for row index and third is for column.  In the example shown the index values (2,0,3)  is used to access element 24.

Types of arrays -3 dimensional array

You may like these posts

  •  Calculation of addressThis article focuses on calculating the address of any element in a 1-Dimensional, 2-Dimensional, and 3-Dimensional array in Row major order and Column …
  •  Classification of Data Structure: Data structure has many different uses in our daily life. There are many different data structures that are used to solve different mat…
  •  Abstract Data TypesAbstract Data type (ADT) is a type (or class) for objects whose behavior is defined by a set of values and a set of operations. The definition of ADT only …
  •  What is Data StructureA data structure is a storage that is used to store and organize data. It is a way of arranging data on a computer so that it can be accessed and update…
  •  Types of arraysOne-dimensional ArrayTwo-dimensional ArrayThree-dimensional ArrayTwo dimensional and three dimensional arrays are also called multi-dimensional arrays. in type…
  •  ArraysAn array is a linear data structure and it is a collection of items stored at contiguous memory locations. The idea is to store multiple items of the same type together…

Post a Comment

© 2025Data structures. The Best Codder All rights reserved. Distributed by