Purchase Solution

C++ ordered binary tree: inorder, preorder, postorder

Not what you're looking for?

Ask Custom Question

Write a C++ program to read in a set of numbers from an input file and build an ordered binary tree. For this tree, compute and print the following.

a. Print out the tree in inorder.
b. Print out the tree in preorder.
c. Print out the tree in postorder.
d. Print out the number of nodes in the tree. (Traverse the tree and count the nodes.)
e. Sum up all the values in the tree and compute the average.
f. Count the number of leaves in the tree.
g. Print the value that is the deepest in the tree.

Input file is named as "TreeData.dat".

I am stuck on this binary tree program. I have attached my code and data file.

Purchase this Solution

Solution Summary

Solution shows how recursion can be used to accomplish the given tasks. Recursion makes it easy to understand what is going on, apart from neat looking and compact code.

Solution Preview

Please find attached 535630.cpp that shows how recursion can be used to implement almost every function used in the code to accomplish the given tasks. If you notice carefully, you will see that many of these functions are ...

Purchase this Solution


Free BrainMass Quizzes
C++ Operators

This quiz tests a student's knowledge about C++ operators.

Basic UNIX commands

Use this quiz to check your knowledge of a few common UNIX commands. The quiz covers some of the most essential UNIX commands and their basic usage. If you can pass this quiz then you are clearly on your way to becoming an effective UNIX command line user.

Inserting and deleting in a linked list

This quiz tests your understanding of how to insert and delete elements in a linked list. Understanding of the use of linked lists, and the related performance aspects, is an important fundamental skill of computer science data structures.

C# variables and classes

This quiz contains questions about C# classes and variables.

Javscript Basics

Quiz on basics of javascript programming language.