Features of the linear structure:
In the non-empty finite concentration of the data element, (1) there exists only one data element called "First", (2) There is only one data element called "The Last", (3) Each data element in the set has only one precursor except the first; (4) except the last one, There is only one successor for each data element in the collection.
1. Linear table (linear list) is the most common and simplest kind of data structure. In short, a linear table is a finite sequence of n data elements. As for the specific meaning of each data element, in different situations, it can be a number or a symbol, or a page of books, or even more complex information.
For example, 1:26 English alphabet is the alphabet: (a,b,c,..., Z) is a linear table, the data element in the table is a single alphabetic character.
For example 2: a school from 1978 to 1983 various models of computer ownership changes, can be given in the form of a linear table: (6,17,28,50,92,188), the data element in the table is a whole number.
In a slightly more complex linear table, one data element can consist of several data items (item). A data element is often called a record, and a linear table containing a large number of records is also called a file.
For example, a school's student health registration form shows that each student in the table is a record that consists of 6 data items, such as name, student number, gender, age, class, and health status.
name |
study number |
gender |
|
|
|
Kobayashi |
790631 |
male |
18 |
The |
health |
Chen Hong |
790632 |
female |
20 |
The |
General |
Liu Jianping |
790633 |
male |
21 |
The |
health |
Zhang Lili |
790634 |
Man |
17 |
Count 91 |
Neurasthenia |
. . . |
. . . |
. . . |
. . . |
. . . |
. . . |
Elements in the same linear table must have the same attribute, which is the same data object, and there is a sequence-couple relationship between adjacent data elements. If the linear memento is:
(A1,..., ai-1,ai,ai+1,..., An)
The table ai-1 ahead of Ai,ai in Ai+1, called Ai-1 is the direct precursor of AI, Ai+1 is the direct successor element of AI. When i=1,2,3,... n-1, Ai has and has only one direct successor, and when i=2,3,..., N, Ai has and only one direct precursor.
Method 1: Insert all data elements that are in linear table lb but not in LA
Assuming that two linear tables, LA and LB, represent two sets a and B respectively (that is, the data element in the linear table is a member of the collection), a new collection a=a∪b is now required. This requires a linear table to do the following:
- Expand Linear table LA to insert data elements that exist in linear table lb instead of linear table la into linear table LA.
- As long as each data element is obtained sequentially from the linear table lb and queried in linear table la according to the value, it is sown if it does not exist.
Please write the algorithm implementation
Type definitions for linear tables