-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBST.h
More file actions
54 lines (40 loc) · 1.03 KB
/
BST.h
File metadata and controls
54 lines (40 loc) · 1.03 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
//
// Created by ahmad on 11/19/16.
//
#ifndef BST_BST_H
#define BST_BST_H
#include <ostream>
#define nullptr 0
/**
* For controlling whether which implementation(recursive or non) be used in code
*/
#define BST_ADD_RECURSIVE_IMPLEMENTATION
#define BST_TRAVERSAL_RECURSIVE_IMPLEMENTATION
template <class type> struct BSTNode
{
public:
BSTNode();
BSTNode(type &data);
type data;
BSTNode *leftChild;
BSTNode *rightChild;
};
template <class type> class BST
{
private:
BSTNode<type> *root;
void printPreOrder(BSTNode<type> *root, std::ostream &cout);
void printInOrder(BSTNode<type> *root, std::ostream &cout);
void printPostOrder(BSTNode<type> *root, std::ostream &cout);
void addHelper(BSTNode<type> *root, BSTNode<type> *node);
void deleteTree(BSTNode<type> *root);
public:
BST();
void add(type data);
void printPreOrder(std::ostream &cout);
void printInOrder(std::ostream &cout);
void printPostOrder(std::ostream &cout);
~BST();
};
#include "BST.cpp"
#endif //BST_BST_H