تفاصيل العمل

Student Records Management:

Use single linked list to implements a student records management, it allows user to adding, deleting, displaying and searching for student.

CLASS NODE: student information (id, name, email, phone, address, password, pointer to next node)

CONSTRUCTOR: initialize student data and the pointer = null.

Class student records management:

Function add: to add student at the end of the linked list

If the list empty it return to the head and record, other it traverses to the end and add the new student.

Function delete :delete by the student id

• If the list empty,” no records found”.

• If the id not found, the message “not found”.

• If the student in the list, we traverses the list to find it and delete

• If the student at the head, head pointer will be the next node.

Function display: if it empty “no student available”, other it traverses the list and print.

Course Records Management:

we use binary search tree and search about course information

STRUCT COURSEDATA:

( courseID, courseName,coursecredits,courseinstructor)

CLASS BTNODE :val(to store the course data),*right(pointer to right child),*left(pointer to the left child)

CONSTRUCTOR: to initialize the course data, left=right=nullptr.

CLASS BST: to manage the courses in bst

*root(root node of tree),size(the number of nodes in tree).

CONSTRUCTOR: the root=nullptr, size=0.

FUNCTION ADDCOURSES: it insert a new course in bst

• If the root=nullptr , it will added as new node

• If the courseid of the new course less than the root is courseid,it will be in the left subtree

• If the courseid is greater than the root is courseid , it will be in the left subtree.

• If the course have the same id , it will print that the coure can not be added

FUNCTION MINIMUM:it will find the node with the smallest courseid in subtree and return it

FUNCTION DROPCOURSE: that delete the course from bst

Root(root node of current subtree),id (to delete)

• If the node has no children , it will delete

• If the node has one child, it will replace the node with child

• If the node has two children, it will find the smallest in the right subtree and will replace with the node to be deleted.

Course Enrollment History:

use double linked list

CLASS DLLNODE: string course to hold the course name, pointer next to next node in the list, pointer prev to previous node in the list.

CONSTRUCTOR: initialize the cours to coursename, next=prev=nullptr.

CLASS DLL: in private pointer to the first node and it will be empty.

In public, the constructor to initialize the pointer = nullptr.

FUNCTION ADDCOURSE: it addcourse at the end of the list.

First it create a new node , then check if the list empty(head=nullptr) it will create a new node it will the first node in the list

If the list not empty ,it traverses to the last node, the pointer next will update to point in the new node, the pointer prev will update to point the last node.

FUNCTION DISPLAY: it will display all courses in the list

It start from the head, if the list empty

"No enrollment history available for this student.", if there are courses, it print each courses

Course Prerequisites:

we use stack to checks if the student has complete the requirement to register

FUNCTION VALIDATEPREREQUISITES: it is a Boolean function will return true if the student completed all prerequisites, return false if the student missing any prerequisites, if the student missing any prerequisites it will add to list of missing.

The Parameters: course ID (for the course that student register), student Id(take the student ID),completed courses(the list of course that the student complete),prerequisites(the list of courses need to register)

Course Waitlists:

we use Queue to manage the waitlist.

CLASS QUEUENODE: the class represent (data,QueueNode* next = null)

CONSTRUCTOR: initialize the value to store in the node, and the next=null

CLASS QUEUE: two pointer front in the first node, rear in the last node

CONSTRUCTOR: to initialize the front= rear= nullptr.

Function enqueue: to add new element in the rear

If it is empty , the front= rear= nullptr

Other the new node add after the rear and the pointer will update.

Function dequeue: remove and return to front

If the queue is empty it return -1 and the front = rear=null otherwise it removed the node.

Function display: it print the elements

It iterate from the front to rear

If it empty “waitlist is empty”

Search Optimization:

Function search student: it search by student id , if it found trur ,not false.(we but this function in code in the linked list because it search by id ).

FUNCTION COURSESEARCH:for search a course in binary search tree

*root(the root of the subtree to search), num(courseid of the course to searced)

BASE CASE:if root=nullptr , print"course does not exist on system"

COURSE FOUND: the courseid of current node is the same of num, it means the course exists.

RECURSIVELY SEARCH:If the courseid is greater than the num , it recursively search in the left subtree.

If the courseid is less than the num., it recursively search in the right subtree.

Fast Access:

CLASS HASHTABLE:size(total number that store in hash table), vector<list<pair<int, string>>> table(it is a vector of linked list that store key-value)

CONSTRUCTOR: initialize the size of hash table

FUNCTION INSERT:

• If the key already exists in the corresponding bucket, updates its value.

• If the key does not exist, inserts a new key-value pair into the bucket.

FUNCTION DISPLAY: prints all buckets

FUNCTION SEARCH: search for a key in table,return value if found otherwise return not found

ملفات مرفقة

بطاقة العمل

اسم المستقل
عدد الإعجابات
0
عدد المشاهدات
3
تاريخ الإضافة
تاريخ الإنجاز
المهارات