|
|||
Pre, In, and PostA common problem in data structures is to determine the traversal of a binary tree. There are three classic ways to do it:
See the picture below:
The pre-, in-, and post-order traversals are, respectively, ABCDEF, CBAEDF, and CBEFDA. In this problem, you must compute the post-order traversal of a binary tree given its in-order and pre-order traversals. Input Specification
The input set consists of a positive number C ≤ 2000 that gives the
number of test cases, and C lines, one for each test case. Each test case starts with
a number 1 ≤ N ≤ 52, the number of nodes in this
binary tree. After this, there will be two strings S1 and
S2 that describe the pre-order and in-order traversal of the tree. The
nodes of the tree are labeled with different characters in the range
“ Output SpecificationFor each input set, you should output a line containing the post-order transversal for the current tree. Sample Input
Output for Sample Input
|
|||
University of Debrecen; Faculty of Informatics; v. 09/30/2024 |