Spring 2024 - CS301P - 2
Spring 2024 - CS301P - 2
02
Total Marks: 20
SEMESTER Spring 2024
Due Date: 24-June, 2024
CS301P- Data Structures (Practical)
Instructions
Please read the following instructions carefully before solving & submitting assignment:
It should be clear that your assignment will not get any credit (zero marks) if:
Uploading instructions
For clarity and simplicity, you are required to Upload/Submit only ONE .cpp file.
Objective
The objective of this assignment is
o To make you familiar of Programming with Binary Search Tree Data Structure.
o Learning Insertion deletion and traversing in BST.
GOOD LUCK
Marks: 20
Problem Statement:
Suppose you are a developer, and your task is to develop an Employee Management System for a company. The
system needs to efficiently store employee records and allow for adding and removing employees based on
their unique employee IDs. Use BST(Binary Search Tree) for implementation.
Implementation Details:
1. BST Structure: Each node in the BST represents an employee record, with the employee ID serving as
the key. The BST is organized such that employee records can be efficiently added and removed.
2. Employee Record Structure: Each employee record contains information such as ID and name. The
employee ID serves as a unique identifier for each record.
3. Operations:
Add Employee: Insert a new employee record into the BST based on their employee ID.
Remove Employee: Delete an employee record from the BST based on their employee ID.
Display Employees: Show all employee records from the BST.
4. Data Validation: Implement checks to ensure data correctness, such as validating employee IDs to ensure
they are unique.
5. Error Handling: Handle potential errors gracefully, such as attempting to add a duplicate employee ID or
removing a non-existent employee.
You have to develop classes for Employee, Node, and BST, providing proper encapsulation and abstraction.
Don’t use setter and getter functions in classes instead only use constructor initializer list to set Employee, Node
and BST data members. The main function demonstrates adding and removing employees from the BST and
printing the employee records as per the sample output given at the end of the file.
Note: You must follow the following program structure for naming and to build the program. Also, while
displaying output STUDENT OWN VUID should also be displayed otherwise, you will get ZERO marks.
Program Structure:
Libraries:
Do not use libraries other than these:
#include <iostream>
using namespace std;
class: Employee
Attributes:
1. employeeID: int
2. name: string
Constructor:
1. Employee (…) // Constructor with member initializer list
class : Node
Attributes:
1. employee: Employee // employee class pointer
2. left: Node // left is a pointer of Node class
3. right: Node // right is a pointer of Node class
Constructor:
1. Node (…) // Constructor with member initializer list
class : BST
Attributes:
1. root: Node // root is a pointer of Node class
Constructor:
1. BST() // // Constructor with member initializer list
Functions:
1. insertEmployee(…) // Function to insert a new employee into BST
2. insertEmployeeHelper(…) // Helper function to recursively insert an employee into the BST
3. removeEmployee(…) // Function to remove an employee from BST
4. removeEmployeeNode(…) // Helper function to recursively remove an employee from the BST
5. printBST() // Function to print BST (In-order traversal)
6. printBSTInOrder(…) // Helper function to recursively print the BST (In-order traversal).
7. searchEmployee(…) // Function to search for an employee with a given ID in BST
Default Function:
1. main()