-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBSTNode.cpp
More file actions
48 lines (40 loc) · 1004 Bytes
/
BSTNode.cpp
File metadata and controls
48 lines (40 loc) · 1004 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
41
42
43
44
45
46
47
48
/*
* BSTNode.cpp
*
* Description: Models a node required to build a link-based binary search tree (BST).
*
* Author: AL
* Date of last modification: July 2017
*/
#include "BSTNode.h"
// Constructors
template <class ElementType>
BSTNode<ElementType>::BSTNode() {
left = NULL;
right = NULL;
}
template <class ElementType>
BSTNode<ElementType>::BSTNode(ElementType element) {
this->element = element;
left = NULL;
right = NULL;
}
template <class ElementType>
BSTNode<ElementType>::BSTNode(ElementType element, BSTNode<ElementType>* left, BSTNode<ElementType>* right) {
this->element = element;
this->left = left;
this->right = right;
}
// Boolean helper functions
template <class ElementType>
bool BSTNode<ElementType>::isLeaf() const {
return (left == NULL && right == NULL);
}
template <class ElementType>
bool BSTNode<ElementType>::hasLeft() const {
return (left != NULL);
}
template <class ElementType>
bool BSTNode<ElementType>::hasRight() const {
return (right != NULL);
}