TODO
Top Current: ELF Immediate: Writing an ELF manually Stack For I have so little time.
Top Current: ELF Immediate: Writing an ELF manually Stack For I have so little time.
Count of BSTs catalan numbers but think of the derivation. I can do 1 way for 0 and 1 nodes.
The core idea is simple, you have a pushLeft, on ctor you pushLeft(root) then the next is always the stack top.
The idea that root is the middle element gets you a “balanced” bst.
Inorder traversal ( left → root → right ) is strictly increasing, that much is obvious.
this was a simple problem in the sense that they were looking for a specific optim that was easy to guess than prove that it was needed.
A short note on different BST traversals and if they can be reversed.
Everything in the left subtree is smaller than node. Everything in the right subtree is greater than node.
The invariant is that each node will represent a range of valid values. For a binary tree, one end is unbounded. As you go down you partition ranges.
Common snippets of code that I should remember and do them exactly this way each time to build memory.