-
Notifications
You must be signed in to change notification settings - Fork 0
/
bst.h
56 lines (50 loc) · 1.19 KB
/
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#ifndef bst_h
#define bst_h
#include <iostream>
#include <vector>
using namespace std;
struct node
{
int info;
node *left;
node *right;
};
class BST
{
private:
node *root;
int numElements;
// bool isdegreeZero(node *);
void deepcopy(const BST &other);
public:
void printSpaces(int);
vector<int> getPosition(int);
// node *search(int);
// node *search(node *, int);
BST();
~BST();
BST(int);
int getNumElement();
BST(const BST &other);
BST &operator=(const BST &other);
void insert(int);
void insert(node *, int);
void inorder(node *t);
void inorder();
int height() const;
void height(int, int &) const;
void height(node *, int, int &) const;
int height2();
int height2(node *);
int depth();
int depth(node *);
std::vector<int> getNodeAtLevel(int);
void getNodeAtLevel(node *, int, int, std::vector<int> &);
std::vector<int> getNodeAtLevelnoPos(int) const;
void getNodeAtLevelnoPos(node *, int, int, std::vector<int> &) const;
void display();
void printTree();
friend istream &operator>>(istream &in, BST &a);
friend ostream &operator<<(ostream &out, BST a);
};
#endif