A simple inventory management system demonstrating Binary Search Tree (BST) implementation for efficient product storage and retrieval.
This program manages a product inventory using a Binary Search Tree for fast searching. It demonstrates:
- BST insertion, search, and deletion operations
- Object-oriented programming with C++
- Memory management with pointers
- Product inventory management
g++ -std=c++17 -I include src/*.cpp -o inventory_bst
./inventory_bstmkdir build
cd build
cmake ..
cmake --build .
./bin/InventoryBSTInitial BST and Store Inventory:
Inventory for Tech Store:
Name: Coffee Maker, Price: 99.99, Quantity: 10
Name: Blender, Price: 34.95, Quantity: 15
Name: Microwave, Price: 150, Quantity: 20
BST Listing (sorted by name):
Name: Blender, Price: 34.95, Quantity: 15
Name: Coffee Maker, Price: 99.99, Quantity: 10
Name: Microwave, Price: 150, Quantity: 20
Found product: Blender
Name: Blender, Price: 34.95, Quantity: 15
Deleting 'Blender' from BST:
BST after deletion:
Name: Coffee Maker, Price: 99.99, Quantity: 10
Name: Microwave, Price: 150, Quantity: 20
inventory-bst-cpp/
├── src/ # Source code files
├── include/ # Header files
├── tests/ # Simple unit tests
├── CMakeLists.txt # Build configuration
└── README.md # This file
- Product: Represents individual products with name, price, quantity
- BST: Binary Search Tree for efficient product storage
- Inventory: Manages a collection of products
- Store: Represents a store with inventory management
- Insert: Add products in sorted order (O(log n) average)
- Search: Find products by name (O(log n) average)
- Delete: Remove products from tree (O(log n) average)
- Display: Show all products in sorted order
- Fast Search: O(log n) vs O(n) for linear search
- Sorted Storage: Products automatically sorted by name
- Efficient Operations: Insert, search, delete all in O(log n) time
- Memory Efficient: Only stores what's needed
- Add file I/O to save/load inventory
- Implement tree balancing (AVL tree)
- Add more product attributes
- Create a simple menu interface
- C++17 compatible compiler (GCC, Clang, or MSVC)
- CMake 3.10+ (optional, for CMake build)