Serialise Tree
An interactive, step-by-step visualisation of Serialise Tree.
- Category
- Trees
- Time complexity
- O(n)
- Space complexity
- O(n)
Pseudocode
preorder, writing "#" for every null child
Reference implementation
def serialize(t, out):
if not t: out.append('#'); return
out.append(str(t.v))
serialize(t.l, out); serialize(t.r, out)