Array: Array is a
Data Structure defined by the programmers/users that store data items of the same
type sequentially i.e. an array contains data items of the same type and all these
items are stored sequentially in memory. It is one of the most common user-defined data types used by the programmers.
In this, size of the array needs to be specified during array initialization.
To access
data item at any index, we use array indexing like:
Syntax:
type Array-name[index] // Array-name to be declared by user and type is a type of data to be stored
To access data item at index 2, we write:
type Array-name[2].
Array is widely used by the
programmers because:
It is easy
to implement.
As data
items are stored sequentially and so can be accessed by array indexing in O(1)
time complexity.
Note: here type refers to what type of
data to be stored in the array.
Cheers! Please let me know if you have any queries or feedback on this.
Related common questions: Whats an Array?, Why we use Array?, Use of Array?, What is an Array?