-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBST.h
More file actions
42 lines (33 loc) · 904 Bytes
/
Copy pathBST.h
File metadata and controls
42 lines (33 loc) · 904 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
36
37
38
39
40
41
42
#include <iostream>
#include <string>
struct Node;
class BST {
public:
using KeyType = int;
using ItemType = std::string;
ItemType* lookup(KeyType);
void insert(KeyType, ItemType);
void displayEntries();
void displayTree();
void remove(KeyType);
BST() = default; //BST constructor
///~BST(); //destructor
private:
Node* root = leaf();
static Node* leaf();
static bool isLeaf(Node*);
ItemType* lookupRec(KeyType, Node*);
void insertRec(KeyType, ItemType, Node*&);
void displayEntriesRec(Node*);
void displayTreeRec(Node*, std::string);
void removeRec(KeyType, Node*&);
//Node* detachMinimumNode(Node*&);
///void deepDelete(Node*); //recursive worker performing deep delete
};
struct Node {
BST::KeyType key;
BST::ItemType item;
Node* leftChild;
Node* rightChild;
Node(BST::KeyType, BST::ItemType);
};