Question
*Assignment to follow* In this assignment, you will write a program that inputs values from a file to a Binary Search Tree. See an example
*Assignment to follow* In this assignment, you will write a program that inputs values from a file to a Binary Search Tree. See an example program run below: Example Program Run 1: Enter input filename: HW07_Input1.txt Opening HW07_Input1.txt... Inserting values into binary tree... Printing Values In-Order: 17 238 240 291 299 307 311 421 434 520 534 558 584 600 620 625 639 643 698 701 702 732 761 819 833 835 857 861 880 937 956 967 982 Printing Values Pre-Order: 311 291 238 17 240 299 307 625 600 421 558 534 520 434 584 620 880 701 643 639 698 835 761 702 732 819 833 861 857 967 937 956 982 Printing Values Post-Order: 17 240 238 307 299 291 434 520 534 584 558 421 620 600 639 698 643 732 702 833 819 761 857 861 835 701 956 937 982 967 880 625 311 Printing Leaf Nodes: 17 240 307 434 584 620 639 698 732 833 857 956 982 Example Program Run 2: Enter input filename: HW07_Input2.txt Opening HW07_Input2.txt... Inserting values into binary tree... Printing Values In-Order: 1 2 3 4 5 6 7 8 9 10 Printing Values Pre-Order: 5 3 2 1 4 8 7 6 10 9 Printing Values Post-Order: 1 2 4 3 6 7 9 10 8 5 Printing Leaf Nodes: 1 4 6 9 Assignment Requirements (all must be met to receive full credit): Use the IntBinaryTree implementation from class. Contain program to one .cpp file. Do not separate out solution into 2 or more files. After inputting all values from the input file into the binary tree, your program should print all nodes in-order, pre-order and post-order. Finally, print the leaf nodes: You will add functions to the IntBinaryTree class in order to do this. You will write a private, recursive function to print the leaf nodes within a tree. You will also write a public function which will call the private function - just like the public showInOrder function calls the private displayInOrder function. Remember that a leaf node is defined as a node without a left or right child. Input File: The input file will contain a group of integer values. Every number in the file, including the first, should be stored to your binary tree. When your program begins reading the file, you will not know how many values are in the file. Therefore, you can use a while loop that will keep reading until the end of the file is reached. An example of how to do this is in the File I/O presentation from 10/04.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started