Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Readme.md

🌳 Binary Search Tree Implementation

C++ GCC MIT License

A comprehensive, interactive Binary Search Tree implementation with colorful CLI interface


🚀 Features

🔧 Core Operations

  • 🆕 Dynamic Insertion - Add nodes while maintaining BST property
  • 🗑️ Smart Deletion - Handles all three deletion scenarios
  • 🔍 Fast Search - O(log n) average case lookup
  • 📏 Height Calculation - Recursive tree depth analysis

🌲 Tree Traversals

  • 📊 In-Order - Sorted output (L→R→Rt)
  • 🎯 Pre-Order - Root-first (Rt→L→R)
  • 🔄 Post-Order - Children-first (L→R→Rt)
  • 🎨 Color-coded output for clarity

🎮 Interactive Demo

╔══════════════════════════════════════╗
║        🌳 BST OPERATIONS MENU        ║
╠══════════════════════════════════════╣
║  1. 🆕 Insert Node                   ║
║  2. 📊 In-Order Traversal            ║
║  3. 🎯 Pre-Order Traversal           ║
║  4. 🔄 Post-Order Traversal          ║
║  5. 🔍 Search Node                   ║
║  6. 🗑️  Delete Node                   ║
║  7. 📏 Calculate Height              ║
║  8. 🚪 Exit                          ║
╚══════════════════════════════════════╝

Sample Interaction:

🌳 Enter value to insert: 50
✅ Node 50 inserted successfully!

📊 In-Order Traversal: 25 → 50 → 75
📏 Tree Height: 2

🛠️ Compilation & Usage

# Compile
g++ -o bst BSTImplementation.cpp

# Run
./bst

📚 Algorithm Complexity

Operation Average Case Worst Case
Search O(log n) O(n)
Insert O(log n) O(n)
Delete O(log n) O(n)
Traversal O(n) O(n)

🎯 Learning Objectives

  • ✅ Understand BST properties and invariants
  • ✅ Master recursive tree algorithms
  • ✅ Implement complex deletion logic
  • ✅ Practice memory management in C++
  • ✅ Build interactive CLI applications

Happy Coding! 🚀