Class TrieNode
This class is used to construct a Trie data structure, which is a type of search tree used to store a dynamic set or associative array where the keys are usually strings. Each node in the Trie represents a single character of a word, and the path from the root to a node represents a prefix of the word.
-
Field Summary
FieldsModifier and TypeFieldDescriptionThe children of this node, where each key is a character and the value is the corresponding child node.(package private) boolean
Indicates whether this node represents the end of a word. -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
children
The children of this node, where each key is a character and the value is the corresponding child node.This map is used to store the links to the child nodes, allowing the Trie to branch out for each character in the alphabet. The keys in this map are characters, and the values are the TrieNode instances that represent the next character in the sequence.
-
isEndOfWord
boolean isEndOfWordIndicates whether this node represents the end of a word.This boolean flag is used to mark the end of a valid word in the Trie. When this flag is true, it means that the path from the root to this node forms a complete word that is stored in the Trie.
-
-
Constructor Details
-
TrieNode
public TrieNode()Default constructor for TrieNode.
-