File tree 3 files changed +51
-44
lines changed
main/java/com/thealgorithms/datastructures/tries
test/java/com/thealgorithms/datastructures/tries 3 files changed +51
-44
lines changed Original file line number Diff line number Diff line change 1
- package com .thealgorithms .tries ;
2
-
3
- import java .util .HashMap ;
4
- import java .util .Map ;
5
-
6
- /**
7
- * TrieNode class which holds the characters and references to its child nodes
8
- */
9
- class TrieNode {
10
- private Map <Character , TrieNode > children ;
11
- private char letter ;
12
- private boolean end ;
13
-
14
- TrieNode (char letter ) {
15
- this .letter = letter ;
16
- this .children = new HashMap <>();
17
- this .end = false ;
18
- }
19
-
20
- public Map <Character , TrieNode > getChildren () {
21
- return children ;
22
- }
23
-
24
- public void setChildren (Map <Character , TrieNode > children ) {
25
- this .children = children ;
26
- }
27
-
28
- public char getLetter () {
29
- return letter ;
30
- }
31
-
32
- public void setLetter (char letter ) {
33
- this .letter = letter ;
34
- }
35
-
36
- public boolean isEnd () {
37
- return end ;
38
- }
39
-
40
- public void setEnd (boolean end ) {
41
- this .end = end ;
42
- }
43
- }
1
+ package com .thealgorithms .datastructures .tries ;
44
2
45
3
/**
46
4
* Trie class which holds Strings of characters.
Original file line number Diff line number Diff line change
1
+ package com .thealgorithms .datastructures .tries ;
2
+
3
+ import java .util .HashMap ;
4
+ import java .util .Map ;
5
+
6
+ /**
7
+ * TrieNode class which holds the characters and references to its child nodes
8
+ *
9
+ * <a href="https://en.wikipedia.org/wiki/Trie">Wikipedia</a>
10
+ *
11
+ * @author <a href="https://github.com/sailok">Sailok Chinta</a>
12
+ */
13
+ public class TrieNode {
14
+ private Map <Character , TrieNode > children ;
15
+ private char letter ;
16
+ private boolean end ;
17
+
18
+ public TrieNode (char letter ) {
19
+ this .letter = letter ;
20
+ this .children = new HashMap <>();
21
+ this .end = false ;
22
+ }
23
+
24
+ public Map <Character , TrieNode > getChildren () {
25
+ return children ;
26
+ }
27
+
28
+ public void setChildren (Map <Character , TrieNode > children ) {
29
+ this .children = children ;
30
+ }
31
+
32
+ public char getLetter () {
33
+ return letter ;
34
+ }
35
+
36
+ public void setLetter (char letter ) {
37
+ this .letter = letter ;
38
+ }
39
+
40
+ public boolean isEnd () {
41
+ return end ;
42
+ }
43
+
44
+ public void setEnd (boolean end ) {
45
+ this .end = end ;
46
+ }
47
+ }
Original file line number Diff line number Diff line change 1
- package com .thealgorithms .tries ;
1
+ package com .thealgorithms .datastructures . tries ;
2
2
3
3
import java .util .List ;
4
+
5
+ import com .thealgorithms .datastructures .tries .Trie ;
4
6
import org .junit .jupiter .api .Assertions ;
5
7
import org .junit .jupiter .api .Test ;
6
8
You can’t perform that action at this time.
0 commit comments