Dsa
Trees
Medium
Serialize and Deserialize Binary Tree
Design a serialization and deserialization scheme for a binary tree. The serialization should convert a binary tree into a string representation, while the deserialization should convert the string back into the original binary tree structure.
Input format:
The input contains a string that represents the level order traversal of the tree, where 'null' is used to indicate non-existent children. The tree is guaranteed to be complete.
Output format:
Print the serialized string representation of the tree and then the deserialized tree's level order as a string.
Example:
Input:
1,2,3,null,null,4,5
Output:
1,2,3,null,null,4,5
1,2,3,null,null,4,5
Key concepts
treesserializationdeserialization
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now