Data structure - head and tail interpolation interpolation

Head and tail interpolation interpolation

1. Definition of nodes
Here Insert Picture Description
benefits of using the head node 2.
Here Insert Picture Description
Here Insert Picture Description
3. The first interpolation method uses the list to establish
the method starts from an empty table, generate a new node, the read data stored in the data field of the new node, and the new the current node into the linked list header, i.e., after the head node.
When using the interpolation method to establish the first single chain, and data read sequence order of the elements in the list generated is reversed. Each node of the insertion time O (1), provided single chain length is n, then the total time complexity is O (n).
Here Insert Picture Description4. Establishment of tail-chain interpolation
algorithm head interpolation method to establish a single linked list is simple, but inconsistent sequential order and input data node in the linked list generated. If desired both a consistent order, the method may be employed tail plug, which is inserted into the new current node of the tail of the linked list, this must add a tail pointer r, always point to the end of the current node list.
Because a pointer attached to the tail of the node pointer, so that the time complexity of interpolation and the same head.
Here Insert Picture Description

Published 33 original articles · won praise 1 · views 2043

Guess you like

Origin blog.csdn.net/m0_45025658/article/details/104885496