-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTrie.java
49 lines (37 loc) · 938 Bytes
/
Trie.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
public interface Trie {
/**
* Adds the specified word to the trie (if necessary) and increments the word's frequency count
*
* @param word The word being added to the trie
*/
void add(String word);
/**
* Searches the trie for the specified word
*
* @param word The word being searched for
*
* @return A reference to the trie node that represents the word,
* or null if the word is not in the trie
*/
Node find(String word);
/**
* Returns the number of unique words in the trie
*
* @return The number of unique words in the trie
*/
int getWordCount();
/**
* Returns the number of nodes in the trie
*
* @return The number of nodes in the trie
*/
int getNodeCount();
interface Node {
/**
* Returns the frequency count for the word represented by the node
*
* @return The frequency count for the word represented by the node
*/
int getValue();
}
}