Starting Out with C++
Starting Out with C++
8th Edition
ISBN: 9780133888201
Author: GADDIS
Publisher: PEARSON CUSTOM PUB.(CONSIGNMENT)
bartleby

Concept explainers

Question
Book Icon
Chapter 20, Problem 8PC
Program Plan Intro

Employee Tree

Program Plan:

BinaryTree.h:

  • Create a template prefix and define the template class BinaryTree to perform the following functions:
    • Declare the required variables.
    • Declare the function prototypes.
    • Define the no-argument generic constructor BinaryTree() to initialize the root value as null.
    • Call the functions insertNode(),displayInOrder(), and searchNode().
    • Define the generic function insert () to insert the node in pointed by the tree node pointer in a tree.
    • Define the generic function insertNode() to create a new node and it is passed inside the insert() function to insert a new node into the tree.
    • Define the generic function searchNode() to search the value in the tree. If it is present, then the function returns a pointer to the value member of the node otherwise it returns false.
    • Define the generic function displayInOrder()to display the values in the subtree pointed by the node pointer.

Employee.h:

  • Create the header file for employee class.
  • Include the required header files.
  • Create the Employee class.
    • Declare the variables.
    • Declare the friend function BinaryTree to pass the instance of employee class nodes.
    • Create the constructor for Employee() class and assign the corresponding variables for employee identification number and name.
    • Define the method setID() to assign the employee ID.
    • Define the method setName() to assign the string to employee name.
    • Define the method getID() to return the value of employee ID.
    • Return the Boolean value using equal operator to check if the returned employee matches with the value.
    • Using friend class return the employee id number and name using stream object.

Main.cpp:

  • Include the required header files.
  • In main() function,
    • Declare the variable.
    • Create the object for BinaryTree.
    • Create the data for employee workers from 1 to 8 individually using the object.
    • Call the function insertNode() to put the employee information into tree.
    • Call the function displayInOrder() to display the tree in order.
    • Prompt the user to enter the employee number.
    • Then call the searchNode() function to search the employee in the tree and assign the information to the pointer.
    • If the pointer is found then print the corresponding message otherwise print the error message.
    • Return the values.

Blurred answer
Students have asked these similar questions
Text concordance using BST 1         Project description Write a cross-reference program that constructs a binary search tree (any type, including splay tree) with all words included from a text file and records the positions (word or line numbers) on which these words were used. These line numbers should be stored on linked lists associated with the nodes of the tree. After the input file has been processed, print in alphabetical order all words of the text file along with the corresponding list of numbers of the lines in which the words occur. 2         What to turn in You will turn in a short written report containing: A description of the significant choices/issues in the design of your code. The source-code of your program. 3         Coding standards A percentage of your grade will be based on the quality of your code, so pay attention to it. Discuss changes (if any) you made to programs presented in class. Take extra care in documenting the code you are implementing on your…
C++ DATA STRUCTURES Implement the TNode and Tree classes. The TNode class will include a data item name of type string,which will represent a person’s name. Yes, you got it right, we are going to implement a family tree!Please note that this is not a Binary Tree. Write the methods for inserting nodes into the tree,searching for a node in the tree, and performing pre-order and post-order traversals.The insert method should take two strings as input. The second string will be added as a child node tothe parent node represented by the first string. Hint: The TNode class will need to have two TNode pointers in addition to the name data member:TNode *sibling will point to the next sibling of this node, and TNode *child will represent the first child ofthis node. You see two linked lists here??? Yes! You’ll need to use the linked lists
Book{ AvlNode{ AvlTree{String title Book insert()int ID int height printTree()String author AvlNode left height()double price AvlNode right max()} } }From your understanding of AVL trees, implement the four different types of rotations and node swoping inside AvlTree.java; each question must be completed with inline Javadoc and/or comments:1. rotRight(AvlNode someNode) and returns AvlNode.2. rotLeft(AvlNode someNode) and returns AvlNode.3. doubleRotLeft(AvlNode someNode) and returns AvlNode. 4. doubleRotRight(AvlNode someNode) and returns AvlNode. 5. Complete a driver code under the main method
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education