Company: Samsung

Difficulty: medium

Problem Statement

Re-Serialize a Binary Tree in Preorder Serialization is the process of converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or transmitted across a network connection link to be reconstructed later in the same or another computer environment. In this problem you have to do both halves of that round trip, between two different formats. You are given a binary tree written in the level-order format . Deserialize it into a tree, then serialize that tree again in the preorder format , and print the result. The two formats Level-order format (the input). The whole tree is one line: the node values in breadth-first order, separated by commas, wrapped in square brackets, with the word null where a child is absent. The children of a null entry are never listed, and the array never ends with a null entry. An empty tree is written [] . For example, [1,2,3,null,null,4,5] is the tree 1 / \ 2 3 / \ 4 5 Preorder format (the output). Visit

More Samsung OA questionsInterview experiences