Stage 1 · Code
Trees
Tree Traversals
Morris traversal, iterator pattern, and serialization.
Morris Traversal (O(1) Space)
Morris traversal achieves inorder without stack/recursion by temporarily threading tree. Find predecessor, link to current, traverse left, then remove link.
BST Iterator
Implement iterator over BST with next() and hasNext() in O(1) amortized. Use controlled inorder traversal with stack. Partial traversal on demand.
Serialization/Deserialization
Convert tree to string and back. Preorder with 'null' markers is standard. Deserialize using queue/index to rebuild.
Mark this lesson complete to store local progress and unlock a cleaner resume path the next time you visit.