Open In App

Subarray meaning in DSA

A subarray is a portion of an array that consists of consecutive elements from the original array.

Subarray

Characteristics of a Subarray:

Difference between Subarray and subsequence:

Subarray  Subsequence
A sequence that is formed by picking any number of consecutive elements from an array  Sequence that is formed by deleting any number of elements from any position of the array
Elements are consecutive and in the same order as in the original array Not necessarily consecutive but in the same order as in the original sequence
All subarrays are also a subsequence of the array Not all subsequences are subarrays.
The number of possible subarrays is less The number of possible subsequences is more

Applications of Subarray:

What else can you read?

  1. Subarray, Subsequences and Subsets in Array
  2. Subarray vs Subsequence
Article Tags :