Linear table

1. A linear table is a collection of zero or more data elements

2. The data elements in the linear table are ordered

3. The number of data elements in the linear table is limited

4. The data elements in the linear table must be of the same type

5. Definition: A linear table is a finite sequence of n data elements of the same type

6. Properties:

            a0 is the first element of the linear list and has only one successor

            an is the last element of the linear list and has only one predecessor

            Elements ai other than a0 and an have both predecessors and successors

            Linear lists are capable of item-by-item and sequential access

7. Linear represents an ordered and finite set of data elements

8. The data elements in the linear table must be of the same type

9. Linear table can be used to describe the problem of "queue type" relationship

10. Common operations

        (1) Create a linear table

        (2) Destroy the linear table

        (3) Clear the linear table

        (4) Insert elements into linear table

        (5) Remove elements from the linear table

        (6) Get an element at a certain position in the linear table

        (7) Get the length of the linear table

11. Linear tables are represented in programs as a special data type

12. The operation of the linear table is realized in the program as a set of functions

13. The linear table is realized in the program as a special data type

14. The operation of the linear table is expressed as a set of related functions

15.

The sequential storage structure of the linear table refers to storing the data elements of the linear table in sequence with a segment of storage units with consecutive addresses.

16. In C language, one-dimensional arrays can be used to implement sequential storage structures

(1) The starting position of the storage space: the array node

(2) Maximum capacity of linear table: array length MAXSIZE

(3) The current length of the linear table: length

17. Get elements

        (1) Determine whether the linear table is legal

        (2) Determine whether the location is legal

        (3) Get elements directly by subscripting the array

18. Insert element operation

algorithm

        (1) Determine whether the linear table is legal

        (2) Determine whether the insertion position is legal

        (3) Move the last element to the element at the insertion position by one position

        (4) Insert a new element

        (5) Add 1 to the length of the linear table

19. Delete element operation

algorithm

        (1) Determine whether the linear table is legal

        (2) Determine whether the deletion location is legal

        (3) Take the element out

        (4) Move the elements after the deleted position forward by one position respectively

        (5) Decrease the length of the linear table by 1

20. Create reusable sequential linear tables

21. Chain storage:

Definition: In order to represent the logical relationship between each element and its immediate successor, each element needs to store information indicating its immediate successor in addition to its own information;

22. Chained storage logical structure

A structure in which n nodes are linked into a linked linear list is called a linked list, and when each node contains only one pointer field, it is called a singly linked list

23.

Header node: The first node in the linked list, containing a pointer to the first data element and some information about the linked list itself

Data Node: A node representing a data element in a linked list, containing a pointer to the next data element and information about the data element

Tail node: the last data node in the linked list, its next element pointer is empty, indicating that there is no successor

24. In C language, structures can be used to define pointer fields in linked lists

25. The header node in the linked list can also be implemented with a structure

26. Get the pos-th element operation

        (1) Determine whether the linear table is legal

        (2) Determine whether the location is legal

        (3) After moving pos times through the next pointer from the header, the next pointer of the current element points to the element to be obtained

27. Algorithm for inserting element to position pos

        (1) Determine whether the linear table is legal

        (2) Determine whether the insertion position is legal

        (3) After moving pos times through the next pointer from the header, the next pointer of the current element points to the position to be inserted

        (4) Insert a new element

        (5) Add 1 to the length of the linear table

28. Algorithm to delete the posth element

        (1) Determine whether the linear table is legal

        (2) Determine whether the insertion position is legal

        (3) Get the posth element

        (4) Delete the posth element from the linked list

        (5) Decrease the length of the linear table by 1

29. Definition of static linked list

(1) The elements in the sequence table array consist of two data fields: Data and next

(2) The data field is used to store data

(3) The next field is used to store the subscript of the next element in the array

30. Get the pos-th element operation

        (1) Determine whether the linear table is legal

        (2) Determine whether the location is legal

        (3) After moving pos times through the next field from the header, the next field of the current element is to obtain the subscript of the element in the array

31. Algorithm for inserting element to position pos

        (1) Determine whether the linear table is legal

        (2) Determine whether the insertion position is legal

        (3) Find the free position index in the array

        (4) After moving pos times through the next field from the header, the next field of the current element is the position to be inserted

        (5) Insert a new element

        (6) Add 1 to the length of the linear table

32. Algorithm to delete the posth element

        (1) Determine whether the linear table is legal

        (2) Determine whether the insertion position is legal

        (3) Get the posth element

        (4) Delete the posth element from the linked list

        (5) Decrease the length of the linear table by 1

33. A singly linked list can be used to represent any linear relationship

Some linear relationships are cyclic, i.e. there are no tail elements

Definition of circular linked list:

Point the next pointer of the last data element in the singly linked list to the first element

34. The circular linked list has all the operations of the singly linked list (developed from the singly linked list, basically the same as the singly linked list, it needs to be rewritten)

        (1) Create a linked list

        (2) Destroy the linked list

        (3) Get the length of the linked list

        (4) Clear the linked list

        (5) Get pos element operation

        (6) Insert element to position pos

        (7) Delete the element at position pos

35. The nodes of a singly linked list have only one pointer to the next node

The data elements of the singly linked list cannot directly access its predecessor elements, and it is an extremely time-consuming operation to access the elements in the singly linked list in reverse order.


36. Definition of doubly linked list

Add a pre pointer to its predecessor in the node of the singly linked list

37. Doubly linked list has all operations of singly linked list

        (1) Create a linked list

        (2) Destroy the linked list

        (3) Get the length of the linked list

        (4) Clear the linked list

        (5) Get the pos-th element operation

        (6) Insert element to position pos

        (7) Delete the element at position pos


Guess you like

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