An Improved Algorithm for Constructing Binary Trees Using the Traversal Sequences

The present algorithm can not be applied to construct a binary tree by using the traversal sequences in which there are same elements. That is to say, the previous algorithms require there are not same elements in the binary tree. This paper designs an improved recursive algorithm to solve the problem. Based on the existing recursive algorithm, this algorithm introduces flag sequences for the traversal sequences. According to the relationship among the elements in the flag sequences, it is theoretically proved that there are three recursive algorithms that can construct binary trees from the traversal sequences. Simulation results show that the algorithm designed in this paper can construct binary trees through the traversal sequences in which there are same elements.