-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFacultyBST.cpp
More file actions
35 lines (28 loc) · 850 Bytes
/
FacultyBST.cpp
File metadata and controls
35 lines (28 loc) · 850 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include "FacultyBST.h"
void FacultyBST::print(){
printHelper(LazyBST::getRoot());
}
void FacultyBST::printHelper(TreeNode<Faculty*>* node){ //prints data in order
if (node== NULL)
return;
printHelper(node->left);
node->key->print();
printHelper(node->right);
}
Faculty* FacultyBST::search(int idNum){ //special search method that searches based on the studentIDs number, because we do not want to search based on key
if(LazyBST::isEmpty())
return NULL;
TreeNode<Faculty*> *current = LazyBST::getRoot();
while(current->key->getID() != idNum){
if(idNum < current->key->getID()){
current = current->left;
}
else{
current = current->right;
}
if(current == NULL){
return NULL;
}
}
return current->key;
}