File tree Expand file tree Collapse file tree 1 file changed +92
-0
lines changed
Interview Prep/section18_Tries Expand file tree Collapse file tree 1 file changed +92
-0
lines changed Original file line number Diff line number Diff line change 1+ package section18_Tries ;
2+
3+ public class TrieClient {
4+
5+ public static void main (String [] args ) throws Exception {
6+
7+ Trie trie = new Trie ();
8+
9+ trie .addWord ("arts" );
10+ trie .addWord ("art" );
11+ trie .addWord ("bug" );
12+ trie .addWord ("boy" );
13+ trie .addWord ("amit" );
14+ trie .addWord ("see" );
15+ trie .addWord ("sea" );
16+ trie .addWord ("seen" );
17+
18+ trie .display ();
19+
20+ System .out .println ("\n SEARCHING..." );
21+ System .out .println (trie .search ("boy" ));
22+ System .out .println (trie .search ("bug" ));
23+ System .out .println (trie .search ("arts" ));
24+ System .out .println (trie .search ("art" ));
25+ System .out .println (trie .search ("amit" ));
26+ System .out .println (trie .search ("sea" ));
27+ System .out .println (trie .search ("seen" ));
28+ System .out .println (trie .search ("see" ));
29+
30+ // System.out.println(trie.search(""));
31+ System .out .println (trie .search ("arte" ));
32+ System .out .println (trie .search ("seens" ));
33+ System .out .println (trie .search ("nirmal" ));
34+ System .out .println (trie .search ("boi" ));
35+
36+ System .out .println ("\n REMOVING...\n " );
37+ trie .remove ("arts" );
38+ trie .display ();
39+
40+ System .out .println ("\n REMOVING...\n " );
41+ trie .remove ("art" );
42+ trie .display ();
43+ }
44+
45+ }
46+
47+
48+ /* output:
49+
50+ art
51+ arts
52+ amit
53+ bug
54+ boy
55+ sea
56+ see
57+ seen
58+
59+ SEARCHING...
60+ true
61+ true
62+ true
63+ true
64+ true
65+ true
66+ true
67+ true
68+ false
69+ false
70+ false
71+ false
72+
73+ REMOVING...
74+
75+ art
76+ amit
77+ bug
78+ boy
79+ sea
80+ see
81+ seen
82+
83+ REMOVING...
84+
85+ amit
86+ bug
87+ boy
88+ sea
89+ see
90+ seen
91+
92+ */
You canβt perform that action at this time.
0 commit comments