Linear table: 1. What is a linear table

Linear table is the simplest data storage structure in data structure, which can be understood as "linear table".

Linear means that the data has a linear relationship in its logical structure. The storage structure used to store data with a linear relationship into a computer is called a linear table .

A linear relationship means that the data are placed next to each other and the population is linearly distributed. Just like in the game "The eagle catches the chicken", the chickens are all holding hands, and the relationship between them can be called a linear relationship .

In other words, the data in the linear table is logically next to each other (hand in hand) with no gaps in between. For each data element, only one data can be found in front of it and it is next to it, and there is only one data next to it in the back. In this way, the data is linearly distributed in the logical structure, and such a storage structure is called a linear table.

The linear table only has requirements for the logical structure of the data. According to the physical structure of the actual storage (decentralized storage or centralized storage), the linear table can also be classified in more detail, which will be introduced in detail at the end of this section.

predecessor and successor

For the data in the linear table, the data before the current data are collectively referred to as " predecessor elements ", and the data immediately preceding them are called " direct predecessors "; similarly, the following data are collectively referred to as " successor elements ", and the following data are collectively referred to as "successor elements". The data next to each other is called " direct successor ". The relationship between the data does not change unless data elements are inserted or removed from the linear table.

  Figure 1 predecessor and successor elements

Data elements, data items, records and files

In a linear table, no matter how many data types the data itself consists of (each is called a " data item "), each piece of data is called a " data element ".

If the data element itself contains a lot of data items, this data element can be called a " record ", and multiple records form a " file ".

Features of Linear Tables

Data stored with linear tables has two characteristics:

  • The type of the stored data itself must remain the same. If it is an int type, it is an int type, and if it is a structure, it is a structure.
  • Once data is stored in a linear table, the relative positions of individual data elements are fixed.
The relative position refers to the sequential order of each data element in the logical structure.

Classification of Linear Tables

As mentioned before, there are two forms of logically adjacent data in actual physical storage: decentralized storage and centralized storage .

Considering these two cases, the linear table is divided into two types to solve the problem of data storage in the two cases:
  • The data elements are stored centrally in the memory, and the structure is expressed in order, referred to as "sequential storage" ;
  • Data elements are stored scattered in the memory, using a chain representation structure, referred to as "chain storage" .

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324661771&siteId=291194637
Recommended