Rebuilding a Tree from Its Traversals: A Case Study of Program Inversion
نویسندگان
چکیده
Given the inorder and preorder traversal of a binary tree whose labels are all distinct, one can reconstruct the tree. This article examines two existing algorithms for rebuilding the tree in a functional framework, using existing theory on function inversion. We also present a new, although complicated, algorithm by trying another possibility not explored before.
منابع مشابه
An improved algorithm to reconstruct a binary tree from its inorder and postorder traversals
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...
متن کاملAn improved algorithm to reconstruct a binary tree from its inorder and postorder traversals
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...
متن کاملA novel algorithm to determine the leaf (leaves) of a binary tree from its preorder and postorder traversals
Binary trees are essential structures in Computer Science. The leaf (leaves) of a binary tree is one of the most significant aspects of it. In this study, we prove that the order of a leaf (leaves) of a binary tree is the same in the main tree traversals; preorder, inorder, and postorder. Then, we prove that given the preorder and postorder traversals of a binary tree, the leaf (leaves) of a bi...
متن کاملProgramming Research Group A CALCULATIONAL APPROACH TO PROGRAM INVERSION
Many problems in computation can be specified in terms of computing the inverse of an easilyconstructed function. However, studies on how to derive an algorithm from a problem specificationinvolving inverse functions are relatively rare. The aim of this thesis is to demonstrate, in anexample-driven style, a number of techniques to do the job. The techniques are based on theframe...
متن کاملA calculational approach to program inversion
Many problems in computation can be specified in terms of computing the inverseof an easily constructed function. However, studies on how to derive an algorithm froma problem specification involving inverse functions are relatively rare. The aim of thisthesis is to demonstrate, in an example-driven style, a number of techniques to do the job.The techniques are based on the frame...
متن کامل