Types of arrays
There are mainly three types of arrays:
- One Dimensional Array
- Two Dimensional Array
- Three-Dimensional Array
- It is a list of the variable of similar data types.
- It allows random access and all the elements can be accessed with the help of their index.
- The size of the array is fixed.
- For a dynamically sized array, vector can be used in C++
Representation of 1D array:
2. Two Dimensional Array:
- It is a list of lists of the variable of the same data type.
- It also allows random access and all the elements can be accessed with the help of their index.
- It can also be seen as a collection of 1D arrays. It is also known as the Matrix.
- Its dimension can be increased from 2 to 3 and 4 so on.
- They all are referred to as a multi-dimension array.
- The most common multidimensional array is a 2D array.
Representation of 2 D array:
3. Three-Dimensional Array:
A Three Dimensional Array or 3D array in C is a collection of two-dimensional arrays. It can be visualized as multiple 2D arrays stacked on top of each other.
Declaration of Three-Dimensional Array:
We can declare a 3D array with x 2D arrays each having y rows and z columns using the syntax shown below.
Syntax:
data_type array_name[x][y][z];
- data_type: Type of data to be stored in each element.
- array_name: name of the array
- x: Number of 2D arrays.
- y: Number of rows in each 2D array.
- z: Number of columns in each 2D array.
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