Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This programming assignment is to implement the following using either Java or C++. 1. 2. 3. A function/method that take preorder and inorder traversal sequence

This programming assignment is to implement the following using either Java or C++.

1.

2. 3.

A function/method that take preorder and inorder traversal sequence and build the corresponding binary tree. Both traversal sequences are stored as array.

Implement the non-recursive inorder, preorder and postorder traversal of the binary tree.

Implement the binary tree traversal by level, with the level number displayed.

You also have to implement the user interface, to allow user to test your code. You can work as a team of two or work alone. If you work as a team, both of you have to submit the identical work with both names to D2L so that your grade can be recorded.

You must submit the following:

All the source codes

Your source code must be well-documented.

Documentation that describes what you did, and how to run your program

If the input inorder sequence = {2,5,6,10,12,14,15}; and preorder sequence = {10,5,2,6,14,12,15}; Then your output should look like the following : Constructed Tree :

Non-recursive inorder traversal : 2 5 6 10 12 14 15

Non-recursive preorder traversal : 10 5 2 6 14 12 15

Non-recursive postorder traversal : 2 6 5 12 15 14 10

by level traversal with Level number : Level 0 :10

Level 1 : 5 Level 1 :14 Level 2 : 2 Level 2 : 6 Level 2 :12 Level 2 :15

//////////////////////////////////////////////////////////////////////////////

In Java, the given node class should be used-

class Node{ T data;

Node left; Node right; public Node (T data){

this.data = data; left = null; right = null;

} // you may add more stuff here }

////////////////////////////////////////////////////////////////////////////////////////// In C++ , the given node structure or class should be used :

Template  struct Node { 

T value;

Node *left;

Node *right; }; 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started