-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBinary_Search_Tree_v2.h
46 lines (41 loc) · 1.08 KB
/
Binary_Search_Tree_v2.h
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
#ifndef BINARY_SEARCH_TREE_V2_H
#define BINARY_SEARCH_TREE_V2_H
#include <iostream>
#include <vector>
#include <cassert>
#include <deque>
#include <queue>
#include <utility>
#define edl '\n'
template <class T>
struct BST_Node
{
T data{};
BST_Node<T> *left{};
BST_Node<T> *right{};
BST_Node(T data) : data(data) {}
};
template <class type>
class Binary_Search_Tree_v2
{
BST_Node<type> *root{};
void insert_node(type val, BST_Node<type> *node);
bool search_node(type val, BST_Node<type> *node);
void print_in_order_node(BST_Node<type> *node);
void clear(BST_Node<type> *node);
BST_Node<type> *min_node(BST_Node<type> *node);
BST_Node<type> *max_node(BST_Node<type> *node);
BST_Node<type> *delete_node(type target, BST_Node<type> *node);
bool is_bst(BST_Node<type> *node);
public:
Binary_Search_Tree_v2();
~Binary_Search_Tree_v2();
void insert_value(type val);
bool search(type val);
void print_in_order();
type min_value();
type max_value();
void delete_value(type val);
void level_order_traversal();
};
#endif