-
Notifications
You must be signed in to change notification settings - Fork 0
/
BST.h
31 lines (30 loc) · 786 Bytes
/
BST.h
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
using namespace std;
#include <iostream>
template <class T>
class BST {
private:
struct Node {
T val;
Node* left;
Node* right;
Node(T _val):val(_val){};
};
Node* root;
void insert(Node* &node, T val);
void swap(T node1, T node2);
void remove(Node* &node, T val);
bool search(Node* node, T val);
void printInOrder(Node* node);
void printPreOrder(Node* node);
void printPostOrder(Node* node);
void clear(Node* &node);
public:
BST():root(NULL){};
~BST();
void insert(T val);
T remove(T val);
bool search(T val);
void printInOrder();
void printPreOrder();
void printPostOrder();
};