TheAlgorithms/C++ 1.0.0
All the algorithms implemented in C++
Loading...
Searching...
No Matches
trie_tree.cpp File Reference

Implementation of Trie data structure for English alphabets in small characters. More...

#include <array>
#include <cassert>
#include <iostream>
#include <memory>
#include <string>
Include dependency graph for trie_tree.cpp:

Go to the source code of this file.

Classes

class  data_structures::trie
 Trie implementation for small-case English alphabets a-z More...
 

Namespaces

namespace  data_structures
 for IO operations
 

Functions

static void test ()
 Testing function.
 
int main ()
 Main function.
 

Detailed Description

Implementation of Trie data structure for English alphabets in small characters.

Author
@Arctic2333
Krishna Vedala
Note
the function ::data_structure::trie::deleteString might be erroneous
See also
trie_modern.cpp

Definition in file trie_tree.cpp.

Function Documentation

◆ main()

int main ( void )

Main function.

Returns
0 on exit

Definition at line 204 of file trie_tree.cpp.

204 {
205 test();
206
207 return 0;
208}
static void test()
Testing function.

◆ test()

static void test ( )
static

Testing function.

Returns
void

Definition at line 177 of file trie_tree.cpp.

177 {
179 root.insert("Hello");
180 root.insert("World");
181
182 assert(!root.search("hello", 0));
183 std::cout << "hello - " << root.search("hello", 0) << "\n";
184
185 assert(root.search("Hello", 0));
186 std::cout << "Hello - " << root.search("Hello", 0) << "\n";
187
188 assert(!root.search("Word", 0));
189 std::cout << "Word - " << root.search("Word", 0) << "\n";
190
191 assert(root.search("World", 0));
192 std::cout << "World - " << root.search("World", 0) << "\n";
193
194 // Following lines of code give erroneous output
195 // root.deleteString("hello", 0);
196 // assert(!root.search("hello", 0));
197 // std::cout << "hello - " << root.search("world", 0) << "\n";
198}
Trie implementation for small-case English alphabets a-z
Definition trie_tree.cpp:24
void insert(const std::string &str)
Definition trie_tree.cpp:76