
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
- Write a program using c++ to implement a character-based Binary Search Tree (BST). Each node in the BST should be store student name (string) as follows:
class Node{// node 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) 4. Exit
|
and Output/results provided and explain the
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 3 steps with 1 images

Knowledge Booster
Similar questions
- Write a program in C++ to create a Binary Search tree (BST) of integers. The program will perform these operations: Insert node(s), Traverse In-order, Search node, Delete node, Leaf Count, Parent of a node and Quit. Use the header file similar to this: #include #ifndef BT_H #define BT_H using namespace std; class BT { private: struct node { int data; node* left; node* right; }; node* root; public: BT(); bool isEmpty() const { return root == NULL; } void insert(int); void print_inorder(); void inorderTrav(node*); void searchBST (int); void deleteNode(int); int count (); int leafCount(node*); void nodeParent(int); //Constructor //Check for empty //Insert item in BST //In-order traversing driver //In-order traversing //Searches BST for a specific node //Delete item from BST //Count driver //Counts number of leaves in BST //Finds parent of a node }; #endif Use the following menu in your program. MENU 1. Insert node(s) 2. Traverse In-order 3. Search node 4. Delete node 5. Leaf Count 6.…arrow_forwardunique please Your task for this assignment is to identify a spanning tree in one connected undirected weighted graph using C++. Implement a spanning tree algorithm using C++. A spanning tree is a subset of the edges of a connected undirected weighted graph that connects all the vertices together, without any cycles. The program is interactive. Graph edges with respective weights (i.e., v1 v2 w) are entered at the command line and results are displayed on the console. Each input transaction represents an undirected edge of a connected weighted graph. The edge consists of two unequal non-negative integers in the range 0 to 9 representing graph vertices that the edge connects. Each edge has an assigned weight. The edge weight is a positive integer in the range 1 to 99. The three integers on each input transaction are separated by space. An input transaction containing the string “end-of-file” signals the end of the graph edge input. After the edge information is read, the process…arrow_forwardThe Task This assignment requires you to write a non-verbose input-driven java program for m aint aining a binary search tree (BST) of integer elements (negative, zero or positive). The speciality of your BST will be that it will record the frequency of occurrence for each integer element in it. Actions provisioned on the BST. When your program is running, a user should be able to select one of the following actions to be performed on the BST. 1. Insert an element into the BST 2. Sear ch for an element in the BST 3. Find the maximum element from the BST 4. Find the minimum element from the BST 5. Print the elements in the BST in preorder 6. Print the elements in the BST in postorder 7. Print the elements in the BST in inorder 8. Delete an element Anything else to exit the program When the progr am is executed, the user will provide their choice of action on the BST, by entering one of the numbers between 1 to 8 that corre spond to their choice. For example, if the user wishes to insert…arrow_forward
- Suppose we have a singly linked list implemented with the structure below and a function that takes in the head of the list.typedef struct node{int num;struct node* next;} node;int whatDoesItDo (node * head){struct node * current = head;struct node * other, *temp;if (current == NULL)return head;other = current->next;if (other == NULL)return head;other = other->next;temp = current->next;current->next = other->next;current = other->next;if (current == NULL){head->next = temp;return head;}other->next = current->next;current->next = temp;return head;}If we call whatDoesItDo(head) on the following list, show the list after the function has finished.head -> 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 7arrow_forwardHow to announce a Linked List Node with three characters in C language, same as the example shown in teaching materials For example is the following figure. EAT O a. struct Node { char *EAT[3]; struct Node next; } Node; O b. struct { Char Three; Link *Next; }; O c. typedef Linked Node { Character EAT; Arrow Link; O d. struct Node { char Three; Arrow Link; }; O e. typedef structure Node { char Name[3]; structure Node *Next; }; O f. structure List Node { Three Character; Link; } O g. typedef struct Node { char name[3]; struct Node *next; } node_C; Oh. typedef struct Node { char EAT; struct *Next; };arrow_forwardAssume FLAMES game that tests for relationship has to be implemented using a dynamic structure. The letters in the FLAMES stand for Friends, Love, Affection, Marriage, Enmity and Sister. Initially store the individual letters of the word ‘flames’ in the nodes of the dynamic structure. Given the count of the number of uncommon letters in the two names ‘n’, write a program to delete every nth node in it, till it is left with a si ngle node. If the end of the dynamic structure is reached while counting, resume the counting from the beginning. Display the letter that still remains and the corresponding relationship Eg., If Ajay and Jack are the two names, there are 4 uncommon letters in these. So delete 4th node in the first iteration and for the next iteration start counting from the node following the deleted node.arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY

Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON

Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning

Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education

Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY