Implement a dynamic Prefix Tree (Trie) in C++ to store a dictionary of strings and support fast prefix queries:
TrieNode* children[26]: Array of pointers for lowercase English letters ('a' through 'z').bool isEndOfWord: Boolean flag indicating completed word termination.int prefixCount: Number of words passing through this node.Trie(): Constructor initializing root.void insert(const std::string& word): Inserts a word into the trie in $O(L)$ time ($L = \text{word length}$).bool search(const std::string& word) const: Returns true if the exact word exists.bool startsWith(const std::string& prefix) const: Returns true if any word starts with the prefix.int countPrefix(const std::string& prefix) const: Returns the total number of words sharing the prefix.std::vector<std::string> getSuggestions(const std::string& prefix) const: Uses DFS traversal to return all words completing the given prefix."byte", "bytes", "byteslab", "build", "buffer", "bug"."bu" and "byte".[*] Inserted 6 dictionary words into Trie.
search('byteslab'): FOUND
search('bytes'): FOUND
search('byt'): NOT FOUND
startsWith('by'): TRUE
countPrefix('bu'): 3 words
countPrefix('byte'): 3 words
Suggestions for 'bu': buffer, bug, build
Suggestions for 'byte': byte, bytes, byteslab
[✓] Trie Prefix Tree & Autocomplete verified (Time: 0.008s, Memory: 2.2 MB)