This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: CS6140 Advanced Programming Lab Exercise 3 Due - 31 August, 2 pm Problem 1 Write a program to construct a binary tree ( don’t use arrays ), given the inorder and preorder traversals of the binary tree and to display the constructed binary tree in postorder. Use a recursive procedure to display the tree in postorder. The elements of the binary tree are integers. The input and output format is explained below. Input The input file will contain multiple test cases. Each test case contains 3 lines. The first line of the test case contains a integer representing the number of elements in the tree. The following two lines contain space separated list of integers representing the inorder and preorder traversals of the binary tree respectively. The test cases are separated by a line containing $ symbol. After the last test case there will be a line containing $$ (two dollar symbols). Example 3 1 2 3 2 1 3 $ 4 1 2 3 4 2 1 3 4 $$ Output For each test case output the postorder traversal of the constructed binary tree into the output...
View Full Document
This note was uploaded on 09/08/2010 for the course COMPUTERSC cs5800 taught by Professor Narayanaswamy during the Spring '10 term at Indian Institute of Technology, Chennai.
- Spring '10