Iterative Method for Recreating a Binary Tree from its Traversals

Many reconstruction algorithms for binary tree have been discussed in this paper. A particular focus of this paper is on “A new Non-Recursive Algorithm for Reconstructing a Binary Tree from its Traversals”. The computation time required for executing the reconstruction algorithm are O(N) and space complexity is O(NlogN) where N is the number of nodes in the binary tree. This algorithm works well for most of the input cases, but it has some drawbacks. There are some sequences of pre-order and in-order for which no legitimate tree can be constructed but the algorithm didn’t take these cases into consideration and constructed a wrong tree for these cases. In this paper, we have proposed a solution to the problem in the previous algorithm and designed an algorithm which is the modified version of the previous algorithm for generating a correct binary tree. The new modified algorithm is implemented in C language and tested in GCC Compiler in Linux, for all types of input cases. The New modified algorithm works well for all types of input cases. We have calculated the best case time complexity of modified algorithm and show that a correct tree can be reported in O(N) time in best case and O(NlogN) space where N is the number of nodes in the tree. We have discussed some applications of the new modified algorithm in Huffman Coding, compiler design, text processing and searching algorithms.

[1]  Chak-Kuen Wong,et al.  Generating binary trees of bounded height , 1986, Acta Informatica.

[2]  Priti Shankar,et al.  A Note on the Reconstruction of a Binary Tree from its Traversals , 1992, Inf. Process. Lett..

[3]  Mark Allen Weiss,et al.  Data structures and problem solving using Java , 1997, SIGA.

[4]  Sartaj Sahni,et al.  Data Structures, Algorithms and Applications in Java , 1998 .

[5]  Glenn Rowe Introduction to Data Structures and Algorithms with C , 1996 .

[6]  Sushil Jajodia,et al.  Alternative methods for the reconstruction of trees from their traversals , 1987, BIT Comput. Sci. Sect..

[7]  Mark Allen Weiss,et al.  Data structures and algorithm analysis , 1991 .

[8]  David Thomas,et al.  The Art in Computer Programming , 2001 .

[9]  E. Mäkinen Constructing a binary tree from its traversals , 1989 .

[10]  Robert Sedgewick,et al.  Algorithms in C , 1990 .

[11]  Vinu V. Das,et al.  A New Non-recursive Algorithm for Reconstructing a Binary Tree from its Traversals , 2010, 2010 International Conference on Advances in Recent Technologies in Communication and Computing.

[12]  Robert Sedgewick,et al.  Algorithms in Java , 2003 .

[13]  Clyde P. Kruskal,et al.  Searching, Merging, and Sorting in Parallel Computation , 1983, IEEE Transactions on Computers.

[15]  Gen-Huey Chen,et al.  Nonrecursive algorithms for reconstructing a binary tree from its traversals , 1988, Proceedings COMPSAC 88: The Twelfth Annual International Computer Software & Applications Conference.

[16]  Mark Allen Weiss,et al.  Data structures and algorithm analysis in C , 1991 .

[17]  Arne Andersson,et al.  Construction of a Tree From its Traversals in Optimal Time and Space , 1990, Inf. Process. Lett..

[18]  Yedidyah Langsam,et al.  Data structures using C and C , 1989 .

[19]  Gary Lindstrom,et al.  Scanning List Structures Without Stacks or Tag Bits , 1973, Information Processing Letters.

[20]  Suresh Kumar,et al.  Modified Non-Recursive Algorithm for Reconstructing a Binary Tree , 2012 .