Skip to content

1leo1tro/inventory-bst-cpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

C++ Inventory Management with Binary Search Tree

A simple inventory management system demonstrating Binary Search Tree (BST) implementation for efficient product storage and retrieval.

What This Project Does

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

How to Compile and Run

Option 1: Direct Compilation (Easiest)

g++ -std=c++17 -I include src/*.cpp -o inventory_bst
./inventory_bst

Option 2: Using CMake

mkdir build
cd build
cmake ..
cmake --build .
./bin/InventoryBST

Example Output

Initial 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

Project Structure

inventory-bst-cpp/
├── src/           # Source code files
├── include/       # Header files
├── tests/         # Simple unit tests
├── CMakeLists.txt # Build configuration
└── README.md      # This file

Key Classes

  • 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

BST Operations Demonstrated

  • 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

Why Use BST?

  • 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

Future Improvements (Optional)

  • Add file I/O to save/load inventory
  • Implement tree balancing (AVL tree)
  • Add more product attributes
  • Create a simple menu interface

Requirements

  • C++17 compatible compiler (GCC, Clang, or MSVC)
  • CMake 3.10+ (optional, for CMake build)

About

C++ Inventory Management System using Binary Search Tree

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors