Help With Assignments

Got confusion or query ???

Looking for customized, unused and Plagiarism free solutions ???

Submit your assignment here

.00

Keywords

Implement a binary search tree for integers using C++ classes. Your program must be able to add nodes, remove nodes, search for nodes, list nodes in in-order, and display the height of the tree. You must implement the tree yourself and are not allowed to use the C++ standard template library, i.e. you will need to implement a class for the tree and a class for the nodes. Upon starting your program, it will display the prompt bst followed by a space:
bst
The user can then select between the following commands: add, delete, search, inorder,height, and quit.
add
Add takes the value of the node to add as an argument. Your program will create a node and insert it into the corresponding place. Then it will repeat the prompt.
bst add 5 bst add 4
bst
delete
Delete takes the value of the node to delete as an argument. Your program will search for the node and delete it. For this assignment, always replace an interior node by the largest node of the left subtree. Then it will repeat the prompt.
bst delete 4 bst delete 3 bst
search
Search takes the value of the node to search, and returns true if the node exists in the tree, false if the node does not exist. Then it will repeat the prompt.
bst search 5 true bst search 2
false
inorder
This command does not take any arguments. It prints the result of an inorder traversal. The individual numbers are separated by hyphens. Then it will repeat the prompt.
bst inorder 2-5-6 bst
height
This command does not take any arguments. It prints the height of the tree. Recall that a tree consisting only of a root node has a height of 0. Then it willrepeat the prompt.
bst height
2 bst
quit
This command does not take any arguments. It terminates the program.
bst quit
Error Handling
• If the command received from the user input is not supported, print out an error message starting with "Error!". (Do not capitalize the entire word "Error")
Submit AT LEAST the following files:
• Your main file controling the flow of the program
• The prototype files for your tree and node classes
• The implementation files for your tree and node classes.
Example of program execution:
g++ *.cpp
./a.out bst add 2 bst add 8 bst add 3 bst add 10 bst search 2 true bst search 5 false bst inorder 2-3-8-10 bst height
2 bst quit
Your program will be judged on the following:
• 27 points - Passes I/O requirements
• 24 points - Code satisfies requirements of assignment
• 9 points - Professional coding style
- 3 point Adequate comments
- 3 point Modularity (small main function, separate functions, etc) - 3 point Readability (line length, indentation, variable names)
You may use and adapt this class definition
/* Example BST class. You can start with this
 * and adapt it as needed */
#include "Node.h" class BST{
 public:
 BST();
 void add(int value); void remove(int value); bool search(int value); void inorder(); int getHeight(); private:
 Node *root;
};

Question Set #150

Views: 328
File Count: Several files in ZIP archive including complete C++ program
File Format: ZIP File
Editable: Yes
Attachment: Click here to download