implement-trie-prefix-tree 1.0.0
Implement Trie (Prefix Tree)
Loading...
Searching...
No Matches
main.cpp File Reference
#include <bits/stdc++.h>
Include dependency graph for main.cpp:

Go to the source code of this file.

Data Structures

class  trie_node
 Definition for trie tree node. More...
 
class  Trie
 

Functions

int main ()
 Your Trie object will be instantiated and called as such: Trie* obj = new Trie(); obj->insert(word); bool param_2 = obj->search(word); bool param_3 = obj->startsWith(prefix);.
 

Function Documentation

◆ main()

int main ( )

Your Trie object will be instantiated and called as such: Trie* obj = new Trie(); obj->insert(word); bool param_2 = obj->search(word); bool param_3 = obj->startsWith(prefix);.

Definition at line 108 of file main.cpp.

109{
110 unique_ptr<Trie> trie(make_unique<Trie>());
111 trie->insert("apple");
112 cout << "search for apple: " << trie->search("apple") << '\n'; // return true
113 cout << "search for app: " << trie->search("app") << '\n'; // return false
114 cout << "starting with app: " << trie->startsWith("app") << '\n'; // return true
115 trie->insert("app");
116 cout << "search for app: " << trie->search("app") << '\n'; // return true
117 return 0;
118}