Last active
April 24, 2020 17:54
-
-
Save phraniiac/000aa3e84830e9adf6f8dd2ad6175e49 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TrieNode { | |
constructor(node_val, is_leaf) { | |
this.node_val = node_val; | |
// Making this an object for fast lookups. | |
// Assuming unique nodes at all levels. | |
this.children = {}; | |
// We incorporate that some element in the middle can also be a complete path. | |
this.is_leaf = is_leaf; | |
} | |
} | |
class Trie { | |
constructor() { | |
console.log("Constructing Trie Root"); | |
this.root = new TrieNode("root", false); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment