Single chain acyclic operation of the node data structure and algorithm of the base

Insert Node

1  // writing a: 
2 R & lt = p-> pNext; // R & lt temporary variable 
. 3 p-> pNext = Q; // Q node address to be inserted 
. 4 Q-> Next = R & lt;
 . 5  
. 6  
. 7  // writing two: 
. 8 Q-> = p-pNext> pNext; // assign the original point to the next node pointer field of the node pointer field inserted 
. 9 p-> pNext = Q; // original node pointer field is assignment of addresses into the node

 

Delete Node

. 1 R & lt = p-> pNext;
 2  // address of the node to be removed is assigned to a temporary variable, to facilitate the release of the last memory 
. 3  
. 4 p-> = p-pNext> pNext -> pNext; // may be written as r-> pNext
 5  // will later remove the p-node, a node pointer field just behind to p p nodes assigned to node pointer field 
. 6  
. 7  Free (R & lt);
 . 8  // manual release memory

 

Guess you like

Origin www.cnblogs.com/sunbr/p/11318617.html