Briefly describe:
The main implementation of the two operations, Get,set
The value,set used to find the string key value is used to add key-value pairs to the dictionary tree.
This implementation is referenced from algorithms 4th Edition, Robert Sedgewick
const int INF =-(1 <<); struct node{int val; node** Next; Node () {val =-(1 << 30); Next = new node*[256]; for (int i = 0; i < i++) next[i] = NULL; }};class tries{private:node* Root; Node* get (node* root, string key, int d) {if (root = null) return null; if (d = = Key.size ()) return root; Return get (Root->next[key[d]], key, D + 1); } node* Set (node* root, string key, int val, int d) {if (root = NULL) root = new Node (); if (d = = Key.length ()) {root->val = val; return root; } Root->next[key[d]] = set (Root->next[key[d]], key, Val, D + 1); return root; }public:tries (): root (NULL) {} int get (string& key) {node* ans = get (root, key, 0); if (ans = = NULL) return inf; Return ans->val; } void Set (String &Key, int val) {root = set (Root, Key, Val, 0); }};
Basic implementation of the Dictionary tree (Trie) (c + +)