From e6028f7bc329ea122bb8a1a339925e50cb74cf63 Mon Sep 17 00:00:00 2001 From: Manish kumar chaurasia <30630740+kmanish31@users.noreply.github.com> Date: Thu, 10 Oct 2019 23:31:12 +0530 Subject: [PATCH] update iterative_trie.cpp added comments so that it is easily understandable --- Trie/iterative_trie.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Trie/iterative_trie.cpp b/Trie/iterative_trie.cpp index 3735078..a937f22 100644 --- a/Trie/iterative_trie.cpp +++ b/Trie/iterative_trie.cpp @@ -1,3 +1,4 @@ +// C++ implementation of trie #include using namespace std; @@ -11,7 +12,7 @@ int sz = 0; int next[27][MaxN]; int end[MaxN]; bool created[MaxN]; - +// insert key into trie void insert (string &s) { int v = 0; @@ -25,7 +26,7 @@ void insert (string &s) { } ++end[v]; } - +// return true if key present in trie and bool search (string tmp) { int v = 0; @@ -39,9 +40,11 @@ bool search (string tmp) { } int main () { + // keys supports lowercase and uppercase letters string keys[] = {"hi", "hello", "you", "ekta", "me"}; string output[] = {"NO", "YES"}; + // construct trie for (int i = 0; i < 5; ++i) insert (keys[i]);