-
Notifications
You must be signed in to change notification settings - Fork 89
Expand file tree
/
Copy pathnode.h
More file actions
46 lines (36 loc) · 1.3 KB
/
node.h
File metadata and controls
46 lines (36 loc) · 1.3 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
//*****************************************************************************************************
//
// This header file defines a struct template that represents a node in a self-balancing binary
// search tree (AVL tree).
//
//*****************************************************************************************************
#ifndef NODE_H
#define NODE_H
//*****************************************************************************************************
template <typename T>
struct Node {
T value;
int bFactor;
Node<T> *left;
Node<T> *right;
Node();
Node(const T &v, Node<T> *l = nullptr, Node<T> *r = nullptr);
};
//*****************************************************************************************************
template <typename T>
Node<T>::Node() {
value = T(); // T() - default initialization (0 for numbers, empty string for strings, etc.)
bFactor = 0;
left = nullptr;
right = nullptr;
}
//*****************************************************************************************************
template <typename T>
Node<T>::Node(const T &v, Node<T> *l, Node<T> *r) {
value = v;
bFactor = 0;
left = l;
right = r;
}
//*****************************************************************************************************
#endif