I am unclear about the definition of a sub array. Does it mean a contiguous list of indexes , such as a[i..j] or can it be non contiguous, such as a[0], a[5],a[6]
Subarrays are arrays within another array.Subarrays contains contiguous elements whereas subsequences are not.
An Example would make it clear
Consider an array {1,2,3,4}
List of all its subarrays are
{},{1},{2},{3},{4},{1,2},{2,3},{3,4},{1,2,3,4}
List of all its subsequences are {},{1},{2},{3},{4},{1,2},{1,3},{1,4},{2,3},{2,4},{3,4},{1,2,3},{1,2,4},{1,3,4},{2,3,4},{1,2,3,4}
I think the subarray means the array in which the contiguousness is based on the index . for example lets take an example
2 3 1 3 1 (index are 0,1,2,3,4 respectively )
so subarray is 2,3,1 3 (index 0,1,2,3) But (1,2 1) (index 2,0,4) cannot be a subarray coz the indexes are non-contiguous ..
Hope its helpfull ;)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With