Skip to content

Instantly share code, notes, and snippets.

@phraniiac
Last active April 24, 2020 17:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phraniiac/000aa3e84830e9adf6f8dd2ad6175e49 to your computer and use it in GitHub Desktop.
Save phraniiac/000aa3e84830e9adf6f8dd2ad6175e49 to your computer and use it in GitHub Desktop.
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