In this section, we will implement our own prefix tree only made from STL data structures and algorithms.
- We will include all the headers from the STL parts we use and declare that we use the std namespace by default:
#include <iostream> #include <optional> #include <algorithm> #include <functional> #include <iterator> #include <map> #include <vector> #include <string> using namespace std;
- The entire program revolves around a trie for which we have to implement a class first. In our implementation, a trie is basically a recursive map of maps. Every trie node contains a map, which maps from an instance of the payload type T to the next trie node:
template <typename T> class trie { map<T, trie> tries;
- The code for ...