export declare class Trie { private _root; /** * Inserts a word into the trie. * * @param word The word to insert. * * @timeComplexity `O(m)` where `m` is the word's length. */ insert(word: string): void; /** * Searches for a word in the trie. * * @param word The word to search for. * * @timeComplexity `O(m)` where `m` is the word's length. * * @returns True if the word is found, otherwise false. */ search(word: string): boolean; /** * Checks if any word in the trie starts with the given prefix. * * @param prefix The prefix to check. * * @timeComplexity `O(m)` where `m` is the prefix's length. * * @returns True if the prefix is found, otherwise false. */ startsWith(prefix: string): boolean; /** * Deletes a word from the trie. * * @param word The word to delete. * * @timeComplexity `O(m)` where `m` is the word's length. * * @returns True if the word was successfully deleted, false if the * word was not found. */ delete(word: string): boolean; /** * Returns all words in the trie. * * @timeComplexity `O(n * k)` where `n` is the number of words and * `k` is the average length of each word. * * @returns An array of all words stored in the trie. */ getAllWords(): string[]; /** * Checks if the trie is empty. * * @timeComplexity `O(1)` * * @returns True if the trie is empty, otherwise false. */ isEmpty(): boolean; /** * Clears all words from the trie. * * @timeComplexity `O(1)` */ clear(): void; /** * Finds the longest prefix of the given word that exists in the trie. * * @param word The word to find the longest prefix for. * * @timeComplexity `O(m)` where `m` is the word's length. * * @returns The longest prefix found in the trie. */ longestPrefixMatch(word: string): string; /** * Returns a list of all words in the trie with the given prefix. * * @param prefix The prefix to autocomplete. * * @timeComplexity `O(p + k)` where `p` is the prefix's length and * `k` is the total number of characters in the words that match the prefix. * * @returns An array of words that start with the given prefix. */ autocomplete(prefix: string): string[]; private _collectWords; }