A Note on the Reconstruction of a Binary Tree from its Traversals (original) (raw)
Related papers
An improved algorithm to reconstruct a binary tree from its inorder and postorder traversals
2017
It is well-known that, given inorder traversal along with one of the preorder or postorder traversals of a binary tree, the tree can be determined uniquely. Several algorithms have been proposed to reconstruct a binary tree from its inorder and preorder traversals. There is one study to reconstruct a binary tree from its inorder and postorder traversals, and this algorithm takes running time of $ BigO{emph{n}^2} .Inthispaper,wepresent. In this paper, we present .Inthispaper,wepresent proc{InPos} $ an improved algorithm to reconstruct a binary tree from its inorder and postorder traversals. The running time and space complexity of the algorithm are an order of $ BigTheta{emph{n}} $ and $ BigTheta{emph{n}} $ respectively, which we prove to be optimal. The $ proc{InPos} $ algorithm not only reconstructs the binary tree, but also it determines different types of the nodes in a binary tree; nodes with two children, nodes with one child, and nodes with no child. At the end, the $ proc{InPos} $ returns a matrix-based structure t...
Efficient parallel algorithms for tree accumulations
Science of Computer Programming, 1994
Accumulations are higher-order operations on structured objects; they leave the shape of an object unchanged, but replace elements of that object with accumulated information about other elements. Upwards and downwards accumulations on trees are two such operations; they form the basis of many tree algorithms. We present two Erew Pram algorithms for computing accumulations on trees taking O(logn) time on O(n= logn) processors, which is optimal.
Iterative Method for Recreating a Binary Tree from its Traversals
International Journal of Computer Applications, 2012
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.
2012
Binary tree traversal refers to the process of visiting each node in a specified order. Given the inorder traversal of a binary tree, along with one of its preorder or postorder traversals, the original binary tree can be uniquely identified. Many recursive and non recursive method of construction of the tree from inorder and any of the postorder or preorder traversal have been proposed. In this paper one of the proposed algorithms has been examined. This algorithm computes the wrong tree for some input sequences. We show a particular situation in which the algorithm fails and a solution for this situation is proposed. The proposed a modified non-recursive algorithm for reconstructing a binary tree which generates the correct tree otherwise an error has been reported.
2011
This paper presents a new approach of reconstruction of Binary search tree using its Pre order tree-traversal only. There are many approaches given with the help of combination of two-tree traversals. But, in this paper we have not used any other combination of tree traversals to reconstruct the Binary search tree. Our work shows the implementation of this algorithm in C language. Our algorithm is found to be very simple and faster than other non recursive algorithms due to its unique implementation. Due to this reason the time and space complexities are significantly reduced.
It is well-known that, given inorder traversal along with one of the preorder or postorder traversals of a binary tree, the tree can be determined uniquely. Several algorithms have been proposed to reconstruct a tree from its inorder and preorder traversals as well as inorder and postorder traversals. There is no study to focus on reconstructing a binary tree from both its preorder and postorder traversals. In this paper, we proved that given preorder and postorder traversals of a binary tree, the tree may not be identified uniquely, however, determining all the feasible solution(s) is possible. We present the PrePos algorithm, a novel algorithm to reconstruct all the possible binary tree(s) from its preorder and postorder traversals. PrePos algorithm not only finds the all the possible solutions, but also determines different types of the nodes in a binary tree; nodes with two children, nodes with one child, and node with no child. In the end, PrePos returns a matrix-based structure to represent all the binary tree solution(s). By this representation, the number of feasible solution can be counted in linear time.
Efficient implementation of tree skeletons on distributed-memory parallel computers
2006
In this paper, we develop an efficient implementation of two tree accumulations. In this implementation, we divide a binary tree based on the idea of m-bridges to obtain high locality, and represent local segments as serialized arrays to obtain high sequential performance. We furthermore develop a cost model for our implementation. The experiment results show good performance.