-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbinarytree.h
More file actions
66 lines (61 loc) · 1.8 KB
/
Copy pathbinarytree.h
File metadata and controls
66 lines (61 loc) · 1.8 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
55
56
57
58
59
60
61
62
63
64
65
66
#ifndef BINARYTREE_H
#define BINARYTREE_H
#include <iostream>
#include <vector>
class BinaryTree
{
struct Node
{
int value;
Node* left_node;
Node* right_node;
Node(int new_value)
{
value = new_value;
left_node = NULL;
right_node = NULL;
}
Node(Node* source)
{
value = source->value;
left_node = source->left_node;
right_node = source->right_node;
}
};
public:
BinaryTree();
BinaryTree(int new_value);
BinaryTree(const std::vector<int> &values);
BinaryTree(const BinaryTree &rhs);
void Add_Item(int new_value);
void inorder();
void preorder();
void postorder();
bool exists(int value);
void remove(int value);
void copyTree(const BinaryTree &source);
void print(std::ostream &ost);
void nodeCount(BinaryTree &source);
BinaryTree& operator+(const int &value);
BinaryTree& operator-(const int &value);
BinaryTree& operator=(const BinaryTree &source);
friend std::ostream& operator<<(std::ostream &ost, BinaryTree &source);
friend std::istream& operator>>(std::istream &ist, BinaryTree &source);
bool operator == (const BinaryTree &rhs);
bool operator != (const BinaryTree *source);
private:
void Insert(int new_value, Node* &Root);
void pinorder(Node* Root);
void ppreorder(Node* Root);
void ppostorder(Node* Root);
bool pexists(int value, Node* Root);
void premove(int value, Node* Root);
void pcopyTree(Node* &destinationRoot, Node* sourceRoot);
bool compare(Node* lhs, Node* rhs);
void helpPrint(std::ostream &ost, Node * Root);
int countNodes(Node *Root);
Node* root;
Node* find_parent_node(int value, Node* Root);
Node* next_min_value(Node* Root);
};
#endif