Brumski's DSA Learning Project 1.3
For Learning Data Structures and Algorithms in C++
Loading...
Searching...
No Matches
BSTree< T > Class Template Reference

This is a template class that represents a Binary Search Tree. More...

#include <binary_tree.hpp>

Classes

class  BSTNode
 This is a template class that represents a node/element in a Binary Search Tree. More...
 

Public Member Functions

virtual void insert (const T &value)
 Inserts a value into the binary search tree.
 
virtual void display (const bool &ascOrder=true)
 Displays all the values in the binary search tree.
 
virtual bool search (const T &data)
 Searches for an element in the binary search tree.
 

Private Member Functions

virtual std::unique_ptr< BSTNode< T > > insertHelper (std::unique_ptr< BSTNode< T > > &root, std::unique_ptr< BSTNode< T > > &node)
 Helper to BSTree<T>::insert()
 
virtual bool searchHelper (std::unique_ptr< BSTNode< T > > &root, const T &data)
 Helper to BSTree<T>::search()
 

Static Private Member Functions

static void displayHelper (std::unique_ptr< BSTNode< T > > &root, const bool &ascendingOrder=true)
 Helper to BSTree<T>::display()
 

Detailed Description

template<class T>
class BSTree< T >

This is a template class that represents a Binary Search Tree.

It can take any basic C++ data type.

Member Function Documentation

◆ display()

template<class T >
virtual void BSTree< T >::display ( const bool &  ascOrder = true)
inlinevirtual

Displays all the values in the binary search tree.

Parameters
ascendingOrder- boolean variable that will decide if the traversal will be in ascending or descending order

◆ displayHelper()

template<class T >
static void BSTree< T >::displayHelper ( std::unique_ptr< BSTNode< T > > &  root,
const bool &  ascendingOrder = true 
)
inlinestaticprivate

Helper to BSTree<T>::display()

Parameters
root- the root node
ascendingOrder- boolean variable that will decide if the traversal will be in ascending or descending order

◆ insert()

template<class T >
virtual void BSTree< T >::insert ( const T &  value)
inlinevirtual

Inserts a value into the binary search tree.

Parameters
value- The value you want inside the BST

◆ insertHelper()

template<class T >
virtual std::unique_ptr< BSTNode< T > > BSTree< T >::insertHelper ( std::unique_ptr< BSTNode< T > > &  root,
std::unique_ptr< BSTNode< T > > &  node 
)
inlineprivatevirtual

Helper to BSTree<T>::insert()

Parameters
root- the root node
node- a new node

◆ search()

template<class T >
virtual bool BSTree< T >::search ( const T &  data)
inlinevirtual

Searches for an element in the binary search tree.

Parameters
data- the element that you want to search for

◆ searchHelper()

template<class T >
virtual bool BSTree< T >::searchHelper ( std::unique_ptr< BSTNode< T > > &  root,
const T &  data 
)
inlineprivatevirtual

Helper to BSTree<T>::search()

Parameters
root- the root node
data- the element that you want to search for

The documentation for this class was generated from the following file: