-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBinaryTreeClass.cpp
More file actions
40 lines (36 loc) · 951 Bytes
/
BinaryTreeClass.cpp
File metadata and controls
40 lines (36 loc) · 951 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
// Note:- INT_MIN is used to represent NULL here
// Note:- Here Complete Binary Tree is constructed
#include <iostream>
#include <climits>
using namespace std;
class BinaryTree{
// Data Member
int* tree;
int root; // Points to root node
int last; // Points to last Node
int size; // Maximum Capacity of Tree
public:
// Parameterized Constructor
BinaryTree(int size){
this->size = size+1;
tree = new int[size+1];
root = 1;
last = 1;
// Root points to NULL
tree[1] = INT_MIN; // INT_MIN points to NULL here
}
// Member Function
int info(int n);
void insert(int val);
int leftChild(int n);
int rightChild(int n);
void makeEmpty();
int currSize();
int father(int n);
void sibling(int n);
void preOrder(int ptr);
void inOrder(int ptr);
void postOrder(int ptr);
int removeNthNode(int n);
void displayCBT();
};