EBK DATA STRUCTURES AND ALGORITHMS IN C
4th Edition
ISBN: 9781285415017
Author: DROZDEK
Publisher: YUZU
expand_more
expand_more
format_list_bulleted
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
In C++, develop an algorithm that inserts the value val into a binary search tree with root. If the tree is empty, root = null. The algorithm returns the root of the tree containing the added item. You should assume that “new node” creates a new node with data field data and reference fields left (for left child) and right (for right child).
Write a program that is capable of creating a binary tree starting fromthe root node using structures and dynamic memory allocation. Ensurethat the tree constructed is binary. Once the user creates the binary tree
at run-time, your program should also check if the binary tree is a binary-search tree or not. If not, it should output the node at the minimum depth
from the root which violates the condition for a binary search tree.Input: The code initially asks for the root node and then dynamicallycreates a binary tree with non-negative integer values until the user isdone.Output: The output should be a single string displaying ‘YES’ or ‘NO’accordingly if the tree entered is binary search tree or not. If not, it should
1
display: x node at i depth violates the BST conditionExample: One way to do is to ask for the root node to begin with, thenkeep asking for a left/right child; followed by a prompt which shows acurrent root value and asks for its subsequent children and so on. Twospecial…
Write a program to implement phone book dictionaryusing Binary Search Tree which provides followingoperations: (a) add new entry in phone book, (b)remove entry from phone book, (c) search phonenumber (d) list all entries in ascending order of nameand (e) list all entries in descending order of name.
Chapter 13 Solutions
EBK DATA STRUCTURES AND ALGORITHMS IN C
Knowledge Booster
Similar questions
- Write a program that maintains a personal phone book in C. The program allows to:▪ Add and Delete entries from the phone book,▪ Search the phone book for a specific entry by last name or by phone number, and▪ Print out the entire entries in the phone book.The data in the phone book is maintained by storing in memory with the use of a singly linked list, withone list node per entry. Each node contains members for storing a person’s family name, first name, address,and the phone number. Use strings to store this information. The linked list must be kept in increasingalphabetical order, sorted by family name. There are no duplicate entries with the same family nameallowed in the phone book. This program should be menu driven, with the user being offered a choice of the following commandsdescribed below:▪ Insert a new entry into the phone book.The program should prompt the user for a new family name and first name, an address and a phonenumber. This information should be placed in a new…arrow_forwardYou are going to start implementing a classfor creating and storing Binary Search Trees(BST). Each node of this BST will store the roll number, name and CGPA of a student. The classdefinitions will look like: class StudentBST;class StudentNode {friend class StudentBST;private:int rollNo; // Student’s roll number (must be unique)string name; // Student’s namedouble cgpa; // Student’s CGPAStudentNode *left; // Pointer to the left subtree of a nodeStudentNode *right; // Pointer to the right subtree of a node};class StudentBST {private: 3 StudentNode *root; // Pointer to the root node of the BSTpublic:StudentBST(); // Default constructor};Implement the following two public member functions of the StudentBST class: bool insert (int rn, string n, double c)This function will insert a new student’s record in the StudentBST. The 3 arguments of thisfunction are the roll number, name, and CGPA of this new student, respectively. The insertioninto the tree will be done based upon the roll number of…arrow_forwardWrite a program of binary tree using linked list. Elements of this linked list should be of integer type, user will provide values as input for elements of binary tree. Your program should allow insert new node, searching node of a value specified by user in binary tree and if the node on leaf than allow delete the node specified by user.arrow_forward
- Write a program that maintains a personal phone book in C. The program allows to:▪ Add and Delete entries from the phone book,▪ Search the phone book for a specific entry by last name or by phone number, and▪ Print out the entire entries in the phone book.The data in the phone book is maintained by storing in memory with the use of a singly linked list, withone list node per entry. Each node contains members for storing a person’s family name, first name, address,and the phone number. Use strings to store this information. The linked list must be kept in increasingalphabetical order, sorted by family name. There are no duplicate entries with the same family nameallowed in the phone book. This program should be menu driven, with the user being offered a choice of the following commandsdescribed below:▪ Insert a new entry into the phone book.The program should prompt the user for a new family name and first name, an address and a phonenumber. This information should be placed in a new…arrow_forwardJava code that eliminates the binary search's node with the lowest value. returns a reference to its element from a tree. If this tree is empty, it raises an EmptyCollectionException. If the tree is empty, returning a reference to the node with the fewest values produces an EmptyCollectionException.arrow_forwardJava.Given a binary tree, write a function that prints the binary search tree’s nodes level by level, for example the following tree will have the following output statement:1, 2, 3, 4, 5arrow_forward
- Write a program to allow user to create a binary search tree. Your program should display in BFT and DFT (preorder, inorder, and postorder) format.arrow_forwardWrite a Java program that creates and maintains a binary search tree (BST) whose nodes are studentrecords. Each student record (BST node) contains the student’s id (String), name (String) and GPA(float). Use the student id as a key for the BST. The program starts with an empty BST and offers thefollowing menu options to the user repeatedly until the user selects the ‘Q’ option (quit). A: Add a new student record to the BST.Here the user is prompted to enter the new student’s id, name and GPA. The program shoulddisplay an error message if the student id already exists in the BST. F: Find a student record. Here the user is prompted to enter the id of the student to be searched. If found the programdisplays the student id, name and GPA, otherwise the program displays an error message. D: Delete a student record. Here the user is prompted to enter the id of the student record to be deleted. The program shoulddisplay an error message if the student id is not found in the BST.arrow_forwardWrite a Java program that creates and maintains a binary search tree (BST) whose nodes are studentrecords. Each student record (BST node) contains the student’s id (String), name (String) and GPA(float). Use the student id as a key for the BST. The program starts with an empty BST and offers thefollowing menu options to the user repeatedly until the user selects the ‘Q’ option (quit). A: Add a new student record to the BST.Here the user is prompted to enter the new student’s id, name and GPA. The program shoulddisplay an error message if the student id already exists in the BST. B: Find a student record. Here the user is prompted to enter the id of the student to be searched. If found the programdisplays the student id, name and GPA, otherwise the program displays an error message.arrow_forward
- in java : you need to start implementing a class for creating and storing Binary SearchTrees (BST). Each node of this BST will store the roll number, name and CGPA of a student.The class definitions will look like:class StudentBST;class StudentNode {friend class StudentBST;private:int rollNo;string name;Student’s CGPAStudentNode* left; // Pointer to the left subtree of a nodeStudentNode* right; // Pointer to the right subtree of a node};class StudentBST {private:StudentNode* root; // Pointer to the root node of the treepublic:StudentBST(); // Default constructor}; Write a menu-based driver function to illustrate the working of different functions of theStudentBST class. The menu should look like:1. Insert a new student2. Search for a student3. See the list of students4. QuitEnter your choice:arrow_forwardWrite a program in C/C++ to that receives N number of integer values from a user, stores the inputted values in a binary search tree, and performs some basic operations on the tree. The program displays the elements of the binary search tree in in-order traversal. The program then prompts the user to provide an integer number (target value) to search in the tree. If the target value does not appear in the tree, the program inserts the value in an appropriate place according to the property of node insertion of binary search tree. If the target value appears in the tree, the program deletes the target value from the tree and preserves the property of binary search tree. In both cases, the program displays the modified binary search tree in in- order traversal. Your program must contain the following user-defined functions: - insertNode – this function inserts the user’s input and creates a binary search tree. - inOrder – this function displays the entire tree in in-order traversal. -…arrow_forwardWrite a program in C/C++ to that receives N number of integer values from a user, stores the inputted values in a binary search tree, and performs some basic operations on the tree. The program displays the elements of the binary search tree in in-order traversal. The program then prompts the user to provide an integer number (target value) to search in the tree. If the target value does not appear in the tree, the program inserts the value in an appropriate place according to the property of node insertion of binary search tree. If the target value appears in the tree, the program deletes the target value from the tree and preserves the property of binary search tree. In both cases, the program displays the modified binary search tree in in- order traversal. Your output format should be as shown in the test runs. Your program must contain the following user-defined functions: - insertNode – this function inserts the user’s input and creates a binary search tree. - inOrder – this…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education