Skip to content
Home ยป Arrays : Definition and Classification of Arrays

Arrays : Definition and Classification of Arrays

โœ… Arrays: Definition and Classification


โœ… 1. Definition of Array

An Array is a linear data structure used to store multiple values of the same data type in continuous (contiguous) memory locations.

โœ… Each element in an array is accessed using an index (subscript).

๐Ÿ“Œ Example:

int a[5] = {10, 20, 30, 40, 50};

โœ… Here:

  • a is the array name
  • 5 is the size
  • 10, 20, 30, 40, 50 are elements
  • Index starts from 0

๐Ÿ“Œ Indexing:

  • a[0] = 10
  • a[1] = 20
  • a[2] = 30
  • a[3] = 40
  • a[4] = 50

โœ… 2. Characteristics / Features of Array

โœ… Important points:

  1. Stores similar type elements (same data type)
  2. Stored in contiguous memory
  3. Elements are accessed using index
  4. Allows random access (direct access)
  5. Size is usually fixed (static)

โœ… 3. Classification of Arrays

Arrays are classified mainly into the following types:


โœ… (A) One-Dimensional Array (1D Array)

A 1D array stores elements in a single row (linear form).

โœ… Syntax:

datatype array_name[size];

โœ… Example:

int marks[5];

๐Ÿ“Œ Representation:

marks[0]  marks[1]  marks[2]  marks[3]  marks[4]

โœ… Uses:

  • Storing list of marks
  • Roll numbers
  • Temperatures of a week, etc.

โœ… (B) Two-Dimensional Array (2D Array)

A 2D array stores elements in rows and columns (matrix form).

โœ… Syntax:

datatype array_name[rows][cols];

โœ… Example:

int matrix[2][3];

๐Ÿ“Œ Representation:

Row 0 โ†’  a[0][0]  a[0][1]  a[0][2]
Row 1 โ†’  a[1][0]  a[1][1]  a[1][2]

โœ… Uses:

  • Matrix calculations
  • Tables
  • Storing marks of multiple students in subjects

โœ… (C) Three-Dimensional Array (3D Array)

A 3D array stores elements in multiple layers (3 dimensions).

โœ… Syntax:

datatype array_name[x][y][z];

โœ… Example:

int arr[2][3][4];

๐Ÿ“Œ Uses:

  • Advanced matrix operations
  • 3D graphics
  • Scientific calculations

โœ… (D) Multi-Dimensional Array

Arrays with more than 2 dimensions are called multi-dimensional arrays.

โœ… Example:

  • 4D array, 5D array etc. (rare in basic programs)

โœ… 4. Other Classification (Very Useful for Exams)


โœ… 1. Static Array

A Static Array has a fixed size, decided at compile time.

โœ… Example:

int a[10];

๐Ÿ“Œ Advantage:

  • Easy access and fast indexing

๐Ÿ“Œ Disadvantage:

  • Size cannot be changed

โœ… 2. Dynamic Array

A Dynamic Array can grow or shrink during runtime using dynamic memory allocation.

โœ… Example in C using malloc:

int *a = (int*)malloc(n * sizeof(int));

๐Ÿ“Œ Advantage:

  • Memory is used efficiently

๐Ÿ“Œ Disadvantage:

  • Complex handling

โœ… 5. Advantages of Arrays

โœ… Benefits:

  • Easy to store and access data
  • Fast access using index (random access)
  • Simple to use in loops
  • Useful for implementing stacks, queues, matrices

โœ… 6. Disadvantages of Arrays

โŒ Limitations:

  • Fixed size (in static arrays)
  • Insertion and deletion are difficult (need shifting)
  • Wastage of memory if size is larger
  • Stores only same data type elements

โœ… Conclusion

An array is a linear data structure that stores similar type elements in continuous memory locations. Arrays are mainly classified as 1D, 2D, 3D and multi-dimensional arrays, and also as static and dynamic arrays, based on memory allocation.


.