In this program you are to implement a database of student records, using the binary search tree
Question:
In this program you are to implement a database of student records, using the binary search tree abstract data type, implemented as a linked list. This must be written in C, not C++.
The student record will have the following format:
typedef struct studentRec{
int id;
char[] name; //the name has a maximum length of 25 letters
char[] major; //the major array has a max length of 15
int year;
}
You are required to maintain the database by providing the following functionality:
1. Search to see if a record exists in the data base
2. Add a record to the database;
3. Delete a record from the database
4. Update a record in the database
5. Print out all of the records in the database
6. Print out all of the records in the database from a given point
Requirements:
Your program should demonstrate the 6 functionalities described above. These should be implemented as the following functions:
1. initBST: In this function your program should read an input file to obtain the student records then your BST should be populated by adding each of these records to the BST. Your function should return a pointer to the root of the BST. Do not hardcode the name of your input file in your program. It should be a parameter passed to main.
2. Search: This function takes a pointer to the BST, and an integer parameter. It searches the BST for the student with that Id. If the record is found it prints out the record and the function returns 1 otherwise it returns 0;
3. addNode: This function takes a pointer to the BST, an integer, two char arrays and a second integer. It creates a new node and then adds that node in place to the BST and returns a pointer to the modified BST.
4. updateStudent: This function takes a pointer to the BST and two integers. It finds the student whose id is the first integer and updates the year value to
the second integer parameter and returns a pointer to the updated BSGT.
5. deleteStudent: This function takes a pointer to the BST, and the integer id of a student, finds that student record, deletes it (using the predecessor method) and returns the updated BST.
6. print: This function takes a pointer to the BST and prints out all of the student records stored in table form.
Discrete Mathematics and Its Applications
ISBN: 978-0073383095
7th edition
Authors: Kenneth H. Rosen