The sequential representation of a linear table refers to the data elements of a linear table that are stored sequentially with a contiguous set of storage cells.
Assume that each element of a linear table occupies an L storage unit and that the storage address of the first cell that it occupies is the storage location of the data element. The storage position of the i+1 data element in the linear table, loc (ai+1) and the storage location of the first Data element, LOC (AI), satisfies the following relationship:
LOC (ai+1) =loc (AI) +l
In general, the first data element of the linear table is where AI is stored
LOC (AI) =loc (A1) + (I-1) XL
LOC (A1) is the storage location of the first data element in a linear table, often referred to as the starting position or base address of a linear table. As long as the starting position of the storage linear table is determined, any data element in the linear table can be randomly accessed, so the sequential storage structure of the linear table is a random access storage structure.
Attention:
The sequential storage structure of a linear table is characterized by the proximity of two adjacent elements on a logical relationship, so that any element in the table can be randomly accessed, and its storage location is represented by a simple, intuitive formula. On the other hand, however, this feature is also a weakness of this storage structure: a large number of elements need to be moved when inserting or deleting operations.
Demo 1:
Algorithm: Sequential table merging, already sequential linear table LA and LB elements by value non-descending arrangement, merging LA and LB to get new sequential linear table LC,LC elements are also non-descending by value.
Sequential representation and implementation of linear tables