diff --git a/Data Structure/trie.cpp b/Data Structure/trie.cpp new file mode 100644 index 0000000..38eda57 --- /dev/null +++ b/Data Structure/trie.cpp @@ -0,0 +1,83 @@ +#include + +using namespace std; +class trie{ + + public: + char val; + bool end=false; + trie* children[26]={NULL}; +}; + +void insert(trie* root, string str) +{ + trie* temp=root; + for(int i=0; ichildren[str[i]-'a']) + { + temp->children[str[i]-'a']= new trie(); + } + temp=temp->children[str[i]-'a']; + } + temp->end=true; + cout<<"value successfully Inserted"<children[str[i]-'a']==NULL) + { + cout<<" Given value Not Found"<children[str[i]-'a']; + } + if(temp->end==true) + { + cout<<" Given value successfully Found"<children[str[i]-'a']==NULL) + { + cout<<"Given value is not present"<children[str[i]-'a']; + } + + if(temp->end==true) + { + temp->end=0; + cout<<"value successfully deleted"<>str; + insert(root,str); + search(root,str); + del(root,str); + return 0; +}