LINEAR DATA STRUCTURES
LINEAR DATA STRUCTURES
A linear data structure is a data structure where elements are organized sequentially, wherein each element is positioned in a linear order, and traversal typically follows one direction (from start to end).
Static and Dynamic Arrays
Static and Dynamic Arrays
As mentioned, an array is a fixed-length, ordered collection of values of the same type stored in contiguous memory locations. The collection may be ordered in several dimensions.
An array can be considered as the simplest type of data structure, and can be either a one-dimensional array or a two-dimensional array (matrix). They are used to implement tables, especially lookup tables, and lists and strings used by almost every program on a computer.
It can be compared to a series of containers or slots lined up in a row, with each slot containing elements (values or variables). The elements are identified by at least one array index or key.
In programming, here's how an array looks:
int[] array = {two, four, ten, five, fifteen, three};
In the example, array [zero] holds the value of two, array [one] holds the value of four, and so on.