Binary Search Tree (C++)
Loading...
Searching...
No Matches
BST.h
Go to the documentation of this file.
1
15
16#pragma once
17
18#ifndef BST_H
19#define BST_H
20
21#include "Node.h"
22
49
50class BST {
51public:
55 BST();
56
60 ~BST();
61
67 void insert(int value);
68
74 bool search(int value) const;
75
81 void inorder() const;
82
86 void levelOrder() const;
87
93 bool remove(int value);
94
95private:
96 Node* root;
97
102 void destroyTree();
103};
104
105#endif // BST_H
Declaration of the Node class.
void levelOrder() const
Performs a level-order (breadth-first) traversal of the tree.
Definition BST.cpp:127
void inorder() const
Performs an inorder traversal of the tree.
Definition BST.cpp:102
void insert(int value)
Inserts a value into the BST.
Definition BST.cpp:41
BST()
Constructs an empty BST.
Definition BST.cpp:26
bool remove(int value)
Removes a value from the BST if it exists.
Definition BST.cpp:154
bool search(int value) const
Searches for a value in the BST.
Definition BST.cpp:81
~BST()
Destroys the BST and frees all dynamically allocated nodes.
Definition BST.cpp:31
Represents a node within a binary search tree.
Definition Node.h:35