C++ - Binary Search Tree X6

Star InactiveStar InactiveStar InactiveStar InactiveStar Inactive
 

A binary search tree is a technique used to cut down operations for organising and going through data. This was quite a tough concept to understand.


Binary Search Tree:

A binary search tree is basically a type of way of assigning a name or number key to objects and storing them in memory as references. An example is searching for your friend's phone number in your phone using their name. This is mostly an association to an abstract data object or structure.  An example image of a binary search tree below from http://algorithms.tutorialhorizon.com/.

As you can see, in the above image the numbers are the key values and you traverse through the list by using boolean logic operators of greater than or less than.


Video Demonstration:

This is a video demonstrating the binary search tree. The program is kind of buggy though as some features are not fully complete.


Code Explanation:

As you can tell by the code, the data insertion function is missing. The other functions are there though. All previous knowledge from the other programs are present in this program. The tricky thing about this program was understanding how a binary search tree works.


Code:

The code is broken into parts. There is a lot of code in this one. Make sure the file names are the same as the include lines in the code!

Driver.cpp

Show Code

Hide Code

 

BST.cpp

Show Code

Hide Code

 

BST.h

Show Code

Hide Code

 

Extra.h

Show Code

Hide Code


Have Fun:

That's all there is for this article. If you have any questions or comments go ahead and do so below or in the video.

Tags: Computer Science, C++

Comments powered by CComment