The address of the data element in the list is arbitrary.
A set that represents a set of data elements, in which each data element is a node, and the data portion of the node is called the data field of the node. In order to be able to wake up or access the entire list, each node of the linked list should at least contain a location information (often referred to as a pointer field) that points to its immediate successor in physical memory. A node also contains a location information that points to his direct forward element in physical memory. A list of the last node of the pointer field can be empty, the entire linked list of the end.
A linked list of nodes consisting only of a precursor pointer or a successor pointer is called a one-way list, while a linked list with a precursor pointer and a successor pointer is called a two-way list. In practical applications, a head node is usually added to the entire list. This node can be used as an entry point to access the entire list, or as an end tag to traverse the entire list. 1. One-way linked list and its operation
Class Node
{public
:
int data
Node *next;
} Node
(1) Insert Operation
The procedure for inserting a new node x after position I is to generate the new nodes first, and then to modify the position of the adjacent node pointer fields.
S.next=p.next;
P.next=s;
Picture source See watermark
(2) Delete operation
The process of deleting the first node is to determine where you want to delete the node, and then modify the values in the pointer field for the node.
P.next=s.next;
Picture slightly (' ◡ ') (3) Find Operation
Finds a node in the list that has a value of newelement and returns its position in the list if found, otherwise null.
node * Get (Node *plink,int i) {if (null==plink) return Null;
int count=0;
Node * Pnext=plink;
while (Count<i && pnext!=null) {count++;
pnext=pnext->next; return Pnext