Question: 1. Write a program to implement a character-based Binary Search Tree (BST). Each node in the BST should be store student name (string) as follows:






1. Write a program to implement a character-based Binary Search Tree (BST). Each node in the BST should be store student name (string) as follows: class Node {/ode prototype public: char ch;// this letter is taken from student first letter string studentName; Node *leftChild; Node *rightChild; }; } For example, if a student's name is Adam then ch will be equals to A. If the student's name is Lee then ch will be equal to L. The insertion of a node to the BST is based on the first letter of the student name. Your program should display the following: 1. Insert a node (base on ch) 2. Find a node (base on student name) 3. Delete a node (consider all three cases of delete) a 4. Exit Step by step output: 1. Insert a node (base on ch) 2. Find a node (base on student name) 3. Delete a node (consider all three cases of delete) 4. Exit Please select an operation: 1 Please input a name: Lee Display tree 1. Insert a node (base on ch) 2. Find a node (base on student name) 3. Delete a node (consider all three cases of delete) 4. Exit Please select an operation: 1 Please input a name: Adam Display tree L . 1. Insert a node (base on ch) 2. Find a node (base on student name) 3. Delete a node (consider all three cases of delete) 4. Exit Please select an operation: 1 Please input a name: Michele Display tree L M A 1. Insert a node (base on ch) 2. Find a node (base on student name) 3. Delete a node (consider all three cases of delete) 4. Exit Please select an operation: 3 Specify the node you want to delete: Adam Display tree L M . 1. Insert a node (base on ch) 2. Find a node (base on student name) 3. Delete a node (consider all three cases of delete) 4. Exit Please select an operation: 2 Please input a name: Adam Not found 1. Insert a node (base on ch) 2. Find a node (base on student name) 3. Delete a node (consider all three cases of delete) 4. Exit Please select an operation: 4 Exit
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
