Completed BST and most of infrastructure for the whole section
This commit is contained in:
52
Exam/IKT203Exam/Portfolio/Assignment-03/TBST.h
Normal file
52
Exam/IKT203Exam/Portfolio/Assignment-03/TBST.h
Normal file
@@ -0,0 +1,52 @@
|
||||
#ifndef IKT203_COURSE_ASSIGNMENTS_TBST_H
|
||||
#define IKT203_COURSE_ASSIGNMENTS_TBST_H
|
||||
#include "TEmployee.h"
|
||||
|
||||
|
||||
struct Node {
|
||||
int key;
|
||||
TEmployee* data;
|
||||
Node* left;
|
||||
Node* right;
|
||||
};
|
||||
|
||||
|
||||
class TBST {
|
||||
private:
|
||||
Node* root;
|
||||
|
||||
static Node* insert(Node* node, int key, TEmployee* data);
|
||||
|
||||
static Node* search(Node* node, int key);
|
||||
|
||||
static Node* remove(Node* node, int key);
|
||||
|
||||
static void inorder(const Node* node);
|
||||
|
||||
static void preorder(const Node* node);
|
||||
|
||||
static void postorder(const Node* node);
|
||||
|
||||
static void levelorder(const Node* node);
|
||||
|
||||
static void destroy(Node* node);
|
||||
|
||||
static Node* findMin(Node* node);
|
||||
|
||||
public:
|
||||
TBST() = default;
|
||||
~TBST() {destroy(root);}
|
||||
|
||||
void Insert(int key, TEmployee* data);
|
||||
[[nodiscard]] TEmployee* Search(int key) const;
|
||||
void Delete(int key);
|
||||
|
||||
void Inorder() const;
|
||||
void Preorder() const;
|
||||
void Postorder() const;
|
||||
|
||||
void LevelOrder() const;
|
||||
};
|
||||
|
||||
|
||||
#endif //IKT203_COURSE_ASSIGNMENTS_TBST_H
|
||||
Reference in New Issue
Block a user