MCPcopy Create free account
hub / github.com/PrajaktaSathe/Java / search

Method search

Programs/Trie_Implementation.java:35–47  ·  view source on GitHub ↗
(String word)

Source from the content-addressed store, hash-verified

33
34//Search function which searches for the word in the Trie. It returns true if the provided word exists in Trie else returns false
35 public boolean search(String word){
36 TrieNode curr= root;
37
38 for(int i=0; i< word.length(); i++){
39 char ch= word.charAt(i);
40
41 if(curr.children[ch - 'a'] == null) //We pick a char from the given string and keep moving to its children untill we reached its end
42 return false;
43
44 curr= curr.children[ch - 'a'];
45 }
46 return curr.isEnd; //When we reach the even of the provided string we simply return if the end is True or False
47 }
48
49
50 //It returns true if there exists a word which starts with the provided word

Callers 1

mainMethod · 0.95

Calls 1

lengthMethod · 0.80

Tested by

no test coverage detected