出典:Wikipedia
出典:『Wikipedia』 (2011/02/17 21:23 UTC 版)
A sentinel node is a programming idiom used on linked lists and trees as a traversal path terminator. Sentinels are used as an alternative over using null as the path terminator in order to get one or more of the following benefits: (1) Increased speed of operations; (2) Reduced algorithmic code size; (3) Increased data structure robustness (arguably). A sentinel is a specifically designated node that is not a data node of the data structure. Sentinel nodes are often used when implementing linked lists. e.g., Linked list data structures may use a sentinel to indicate the end of a list. Similarly, a tree data structure can use a sentinel to indicate a node without children.