This project is a C++ implementation of a Binary Search Tree (BST) for educational purposes. It is designed for the Analysis and Design of Data Structures and Algorithms Laboratory. The project showcases basic operations of a BST, such as insertion, searching, and traversal.
- Insertion: Adds new nodes to the binary search tree while maintaining the BST property.
- Search: Allows searching for specific values in the tree.
- Traversal: Supports in-order, pre-order, and post-order traversal of the tree.
- Deletion (Planned): Future improvements may include node deletion functionality.
main.cpp
: The main file that demonstrates the use of the BST class by inserting, searching, and traversing nodes.BSTree.h
: Contains the declaration of theBSTree
class which includes methods for tree operations.BSTNode.h
: Defines the structure of a node in the BST.
-
Clone the repository:
git clone https://github.com/netteNz/BST.git cd BST
-
Compile the project (For Linux, ensure you have a C++ compiler like
g++
):g++ main.cpp -o bst
-
Run the executable:
./bst
The project currently provides a simple example in main.cpp
. It demonstrates inserting nodes into the BST and performing various traversals. To modify or test different functionality, you can update the code in main.cpp
.
Example usage:
BSTree tree;
tree.insert(5);
tree.insert(3);
tree.insert(7);
tree.inOrderTraversal(); // Outputs: 3 5 7