bartleby

Concept explainers

Question
Book Icon
Chapter 21, 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
Binary search tree. Write a function named totalSum that takes as parameter the root of the binary search tree(with the following type) and returns the total sum of the numbers in the tree. struct tree{    int data;     struct tree *left, *right; };
In C++
Binary Trees (C++) You will create a class for Emploveelnfo that contains: • Employee ID Number – int Employee Name – string Implement a binary tree whose nodes hold an instance of your Emploveelnfo class. The nodes should be sorted on the Employee ID number. You will have a binary tree class header and implementation file. You can write your main to use the following information to test your tree: Employee Name James B W Bevis Employee ID Number 6702 Romney Wordsworth Revis Jacara Clegg Forbes Kalin Tros 1255 1071 2390 1558 7406 Archibald Beechcroft Penthor Mul Bartlet Finchley 7562 3004 4922 Latham Bine 8483 Jeff Myrtlebank Your program should read an employee ID and display a message telling the user whether it was found in the tree or not. Your main will have one binary tree object and all of the operations on the binary tree will be class methods. Other functions to add • Add function to display the tree • Allow user to add a new employee • Allow user to remove an employee NOTE –…
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