Algorithms_in_C++  1.0.0
Set of algorithms implemented in C++.
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:

Classes

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

Namespaces

 data_structures
 Data-structure algorithms.
 

Functions

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

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

Function Documentation

◆ main()

int main ( void  )

Main function.

Returns
0 on exit
205  {
206  test();
207 
208  return 0;
209 }
Here is the call graph for this function:

◆ test()

static void test ( )
static

Testing function.

Returns
void
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 }
data_structures::trie
Trie implementation for small-case English alphabets a-z
Definition: trie_tree.cpp:25
std::cout
std::vector::insert
T insert(T... args)
test
static void test()
Testing function.
Definition: trie_tree.cpp:178