I went to an interview today where I was asked to serialize a binary tree. I implemented an array-based approach where the children of node i (numbering in level-order trave
Approach 1: Do both Inorder and Preorder traversal to searialize the tree data. On de-serialization use Pre-order and do BST on Inorder to properly form the tree.
You need both because A -> B -> C can be represented as pre-order even though the structure can be different.
Approach 2: Use # as a sentinel whereever the left or right child is null.....