The advantages and disadvantages of the linked list:
Advantages:
There is no limit to space
Insert deletion element quickly
Disadvantages:
The access speed is slow.
Defined:
N-node discrete allocations (not contiguous storage in memory)
Connect to each other through the pointer
Each node has only one predecessor node, each node has only one successor node
The first node has no predecessor node, and the tail node has no subsequent nodes.
First node:
First valid node
Tail Node:
Last valid node
Head node:
The data type of the header node is the same as the type of the first
No valid data is stored, the most front one is
Before the first node, mainly for the convenience of the linked list
The operation.
Head pointer: (pointing to head)
Pointer variable pointing to the head node
Tail pointer:
Pointer to tail node
(The head node may be large, the memory may be large, suppose I want to create a function
Output the value of all linked lists, if you do not use the head pointer type as a parameter, that
The head nodes of different lists are not the same size, so there is no way to find the parameters.
* * Determine that a list requires several parameters: (or if you expect a function to operate on a linked list)
We need to at least receive the information from the list ... )
Only need one parameter: the head pointer, because through it we can launch
All the information for the linked list.
(The list of procedures better be sure to knock out yourself)
Category of linked list: single linked list
Double Linked list:
Each node has two pointer fields
Circular chain List
Can find all the other nodes through any one node
Single linked list pseudo algorithm: 1. Insert node:
Insert a node that is pointed to by Q after the node to which P points:
P Stores the address of the node to which it points, and Q is. The next pointer holds the address of the next element.
q->next=p->next;p->next=q;
can also
r=p->next; p->next=q;q->next=r;
Delete the node following p
P->next=p->next->next can cause memory leaks, unable to locate the node to be deleted, and unable to free memory.
Correct practice: Temporarily define a pointer r to hold the address of the node to be deleted
r=p->next;
p->next=p->next->next;
Free (R);/release memory occupied by the indicated node