Introduction
This assignment provides practical experience with binary trees and binary search trees.
Define a binary search tree node to include
struct binTreeNode
{
int data;
struct binTreeNode * right;
struct binTreeNode * left;
};
main()
Provide the user a menu of the following options:
- Generate Binary Search Tree
- Print the BST in pre-order format
- Print the BST in in-order format
- Print the BST in post-order format
- Print the BST in breadth-first format
- Find a value in the BST
- Find the minimum value in the BST nodes
- Find the maximum value in the BST nodes
- Calculate the average value of the BST nodes
- Find the median value of the BST nodes
- Calculate the sum of the BST nodes
- Count the number of BST nodes
- Delete a value in the BST
- Exit Program
Use a conditional statement to evaluate the users selection
Function to read the data file as nodes of a binary search tree
Read in the contents of data file "AssignmentFourInput.txt" into the node data structure and generate a binary search tree in the order the data is in the file
Function to display the BST in pre-order format
Traverse the BST and display the nodes in pre-order format
Test Case 1
Perform Test Case 1, results in expected outcome
Function to display the BST in in-order format
Traverse the BST and display the nodes in in-order format
Test Case 2
Perform Test Case 2, results in expected outcome
Function to display the BST in post-order format
Traverse the BST and display the nodes in post-order format
Test Case 3
Perform Test Case 3, results in expected outcome
Function to display the BST in breadth-first format
Traverse the BST and display the nodes in breadth-first order
Function to find a value in the BST
Traverse the BST and search for the value the user entered, display to the user the result of their search (i.e. if the value was found or not found)
Test Case 5
Perform Test Case 5, results in expected outcome
Test Case 6
Perform Test Case 6, results in expected outcome
Function to find the minimum value in the BST
Traverse the BST and search for the minimum value in the BST
Test Case 7
Perform Test Case 7, results in expected outcome
Function to find the maximum value in the BST
Traverse the BST and search for the maximum value in the BST
Test Case 8
Perform Test Case 8, results in expected outcome
Function to find the average value of the nodes in the BST
Traverse the BST and calculate the average value of the BST nodes
Test Case 9
Perform Test Case 9, results in expected outcome
Function to find the median value of the nodes in the BST
Traverse the BST and determine the median value of the BST nodes
Test Case 10
Perform Test Case 10, results in expected outcome
Function to find the sum of the values of the BST nodes
Traverse the BST and determine the sum of the values of the BST nodes
Test Case 11
Perform Test Case 11, results in expected outcome
Function to find the count of the of the BST nodes
Traverse the BST and find the count of the BST nodes
Test Case 12
Perform Test Case 12, results in expected outcome
Function to delete a node in the BST
Search the BST for the entered value and delete it
Test Case 13
Perform Test Case 13, results in expected outcome
Exit the program
Write the appropriate code to exit the program
Test Case 14
Perform Test Case 14, results in expected outcome
Compile
Source compiles with no errors
Run
Source runs with no errors
Comments
Source includes comments
Perform the following test cases
- Test case 1Select option 1 then option 2Display the elements of the BST in pre-order format
- Test case 2Select option 3Display the elements of the BST in in-order format
- Test case 3Select option 4Display the elements of the BST in post-order format
- Test case 4Select option 5Display the elements of the BST in breadth-first format
- Test case 5Select option 6Search the BST for a value that exists
- Test case 6Select option 6Search the BST for a value that does not exist
- Test case 7Select option 7Display the minimum value of the BST
- Test case 8Select option 8Display the maximum value of the BST
- Test case 9Select option 9Display the average value of the BST
- Test case 10Select option 10Display the median value of the BST
- Test case 11Select option 11Display the sum of the BST nodes
- Test case 12Select option 12Display the count of the BST nodes
- Test case 13Select option 13Delete a node with a value that exists in the BST
- Test case 13Select option 13Delete a node with a value that does not exist in the BST
- Test case 14Select option 14Program exits