One walk does not save a tree
transcript
Save a tree as text. List the values in preorder. Now load it back. Which tree is it?
The text is one, two, three. A chain to the left fits. A chain to the right fits. So does a node with two children.
Write a hash for every missing child. Now the three texts differ. Each has its own marks. Add commas between tokens.
Six nodes have twelve child slots. Five slots hold nodes. Seven slots are marks. Thirteen tokens in all.
Preorder lists a node, then its left subtree. Then it lists the right subtree. It keeps the order of the nodes. It forgets where each subtree ends.
A hash means no child in this slot. A value means a new node. The marks show where branches stop. So the same tree comes back every time.
One walk loses the shape. Marks keep it. Try it in the lab. Full breakdown in the lecture.