Nonrecursive algorithms for reconstructing a binary tree from its traversals
暂无分享,去创建一个
The authors propose two nonrecursive algorithms for reconstructing the original binary tree from its inorder and preorder traversals. The proposed algorithms proceed in two stages: the first stage establishes the i-p sequence while the second stage reconstructs the binary tree from the i-p sequence. One algorithm, which requires O(N) time, is time-optimal but space-inefficient, while the other requires O(N log N) time and O(N) space. If sorting and binary search are used, then the space required is optimal within a constant factor. If, instead, hashing is used, the computation time required is optimal within a constant factor. Simple modifications of the proposed algorithm can be used to reconstruct the original binary tree from its inorder and postorder traversals.<<ETX>>
[1] Gary D. Knott,et al. A numbering system for binary trees , 1977, CACM.
[2] Sushil Jajodia,et al. Alternative methods for the reconstruction of trees from their traversals , 1987, BIT Comput. Sci. Sect..
[3] Teruo Hikita. Listing and Counting Subtrees of Equal Size of a Binary Tree , 1983, Inf. Process. Lett..