MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / searchAndPrint

Function searchAndPrint

CPP/Tries/autoComplete.cpp:52–73  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50}
51
52void searchAndPrint(vector <pair<string,int> > &words, TrieNode *root, string &prefix){
53 TrieNode *temp=root;
54 int flag=1;
55
56 for (int i=0; i<prefix.size(); i++){
57 if (temp->alphabets[prefix[i]-'a']==NULL){
58 cout << "-1 ";
59 flag=0;
60 break;
61 }
62 temp=temp->alphabets[prefix[i]-'a'];
63 }
64
65 if (flag){
66 for (int i=0; i<temp->indexes.size(); i++){
67 cout << words[temp->indexes[i]].first << " ";
68 }
69 }
70
71 cout << endl;
72
73}
74
75
76

Callers 1

solveFunction · 0.85

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected