Senior
Trees
DSA & Coding Interviews
How do you serialize and deserialize a binary tree?
Short answer: Use preorder with null markers (e.g. "#") or level-order BFS with nulls. Deserialization consumes the same format with a queue/iterator. Clarify the string format with the interviewer first.
Complexity
Time O(n), Space O(n).
Pick one format and stick to it — inconsistency is a common fail point.
Share this Q&A
Share preview image: https://www.toolliyo.com/images/toolliyo-logo.png