Skip to content

Commit ab961b7

Browse files
author
sailok.chinta
committed
feat: move Trie to datastructures subfolder
1 parent 2cd862b commit ab961b7

File tree

3 files changed

+51
-44
lines changed

3 files changed

+51
-44
lines changed

src/main/java/com/thealgorithms/tries/Trie.java renamed to src/main/java/com/thealgorithms/datastructures/tries/Trie.java

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,4 @@
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;
442

453
/**
464
* Trie class which holds Strings of characters.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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+
}

src/test/java/com/thealgorithms/tries/TrieTest.java renamed to src/test/java/com/thealgorithms/datastructures/tries/TrieTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
package com.thealgorithms.tries;
1+
package com.thealgorithms.datastructures.tries;
22

33
import java.util.List;
4+
5+
import com.thealgorithms.datastructures.tries.Trie;
46
import org.junit.jupiter.api.Assertions;
57
import org.junit.jupiter.api.Test;
68

0 commit comments

Comments
 (0)