Skip to content
StackDecode
TreesExplained

Serialize and Deserialize Binary Tree

Write the tree with null markers, then rebuild it from the text.

Time

O(n)

Extra space

O(n)

Use it for

Saving and sending trees.

An animated walkthrough for this algorithm isn’t built yet. The summary above explains the idea; see the related animated algorithms below to practise the same technique.