Lab3 - CS6140 Advanced Programming Lab Exercise 3 Due - 31...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the 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

Page1 / 3

Lab3 - CS6140 Advanced Programming Lab Exercise 3 Due - 31...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online