graphs_cheatsheet
class TreeNode {
constructor(val) {
this.val = val;
this.left = null;
this.right = null;
}
}implement a queue
implement a stack
node,l. subtree, r. subtree
l.subtree, node, r.subtreethe left subtree contains values less than the root
l.subtree, r.subtree, node
BST Definition
l. subtree contains values < root
r. subtree contains values >= to the root
l. & r. subtree are BST
insert: log(n) search: log(n)
Using a node implementation with iteration:
Last updated
Was this helpful?