Rebuilding a Tree from Its Traversals: A Case Study of Program Inversion

نویسندگان

  • Shin-Cheng Mu
  • Richard S. Bird
چکیده

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.

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

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...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

عنوان ژورنال:

دوره   شماره 

صفحات  -

تاریخ انتشار 2003