-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBSTNode.cpp
More file actions
52 lines (48 loc) · 1.17 KB
/
Copy pathBSTNode.cpp
File metadata and controls
52 lines (48 loc) · 1.17 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
/**
* @file BSTNode.h
* @author Alex Lambert
*
* Description:
* - BSTNode keeps a left and right branch, and holds a BSTData item
* - Meant to be used inside a Binary Search Tree
* - Includes no funcitons
*
* Assumptions/Implementation:
* - Left BSTNode and right BSTNode default to
* - When deleting, it deletes its left/right branches first
*/
#include "BSTNode.h"
//---------------------------------------------------------------------------
/** BSTNode()
* Default Constructor
*
* Constructs an BSTNode containing data
* @pre None
* @post BSTNode is initialized with no left/right subtree
*/
BSTNode::BSTNode(BSTData* data)
{
left = nullptr;
right = nullptr;
this->data = data;
}
//---------------------------------------------------------------------------
/** ~BSTNode()
* Default Destructor
*
* Destroys the BSTNode, its left/right subtrees, and its data item
* @pre None
* @post All memory used by the BSTNode and its parts is deallocated
*/
BSTNode::~BSTNode()
{
if (left)
delete left;
left = nullptr;
if (right)
delete right;
right = nullptr;
if (data)
delete data;
data = nullptr;
}