A C++ implementation of a task management system that combines a Binary Search Tree (BST) for active task storage and a Min-Heap for completed task tracking. Built by @omarrashraff and @minshawi0
This system loads tasks from a tasks.txt file into a BST sorted by duration. Users can insert, search, remove, and filter tasks through an interactive menu. When a task is marked as completed, it is moved from the BST into a Min-Heap which stores and sorts completed tasks by duration and generates a category report.
BST.hStores active tasks sorted by duration as the key. Each node holds a description, duration, and category. Supports full BST operations including in-order traversal, search, insert, remove, and range filtering.
Key operations:
INSERT — adds a task node sorted by durationINORDER — displays all tasks sorted by duration (ascending)SEARCH — finds all tasks matching a given durationREMOVE — deletes a task by duration using in-order successor replacementDISPLAYMORETHAN — lists all tasks with duration ≥ a given valueDISPLAYLESSTHAN — lists all tasks with duration ≤ a given valueHeap.hStores completed tasks sorted by duration (shortest first). Implemented as a fixed-size array-based heap with up to 30 tasks. Displays completed tasks in sorted order and generates a category breakdown report.
Key operations:
Insert — adds a completed task and bubbles it up to maintain heap propertyMIN_Heapify — restores heap order downward after extractionDisplayCompleteTasks — prints all completed tasks sorted by duration and outputs a category report (Educational, Health, Food, Others)task-manager-bst-heap-cpp/
├── main.cpp # Menu driver — file loading, BST/Heap interaction, Find_And_Remove
├── BST.h # Node and BST class definitions and implementations
├── Heap.h # Heap class with task struct, insert, heapify, and report
└── tasks.txt # Input file — number of tasks followed by description, duration, category
tasks.txt
3
Buy groceries
30
Food
Morning workout
45
Health
Read a chapter
20
Educational
| Option | Action |
|---|---|
| 1 | Insert a new task into the BST |
| 2 | Display all tasks in sorted order (in-order traversal) |
| 3 | Search for tasks by duration |
| 4 | Remove a task by duration |
| 5 | Display tasks with duration more than a given value |
| 6 | Display tasks with duration less than a given value |
| 7 | Mark a task as completed — moves it from BST to Heap |
| 8 | Display all completed tasks sorted by duration + category report |
| 0 | Exit |
| Concept | Where Used |
|---|---|
| Binary Search Tree | BST.h — sorted insertion, recursive search, in-order successor deletion |
| Min-Heap | Heap.h — array-based heap with bubble-up insertion and heapify |
| File I/O | main.cpp — loads tasks from tasks.txt on startup |
| Case-Insensitive Search | Find_And_Remove — partial description matching with tolower |
| Dynamic Memory | BST nodes allocated with new, deleted on removal |
| Modular Design | Separate .h files for BST and Heap |
g++, clang++)g++ -o task_manager main.cpp
./task_manager
Make sure
tasks.txtis in the same directory as the compiled executable.
These implementations are built for learning and understanding the foundations of tree and heap data structures. No external libraries are used — everything is implemented from scratch.