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 <vector>
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 205 of file trie_tree.cpp.

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

◆ test()

static void test ( )
static

Testing function.

Returns
void

Definition at line 178 of file trie_tree.cpp.

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