Task 2: Data Structure: max-heap & Algorithm: heap sort
This project is inspired by a takeaway experience at a large restaurant where the pickup screen displayed unsorted order numbers. This makes me difficult to locate my order. This drives my interest to explore sorting algorithm as a practical solution for the ordering problem. In this Report, max-heap data structure and heap sort algorithm are selected for detailed study of the priority and sorting mechanism.
This project provides both console-based and Graphic User Interface (GUI) for studying the Max-Heap data structure and Heap Sort algorithm.
-
Console - with detailed step-by-step print statements
main.py
maxHeap.py
heapSort.py
-
GUI Simulator - with data tree visualization, operation logs and step-by-step heap sort anmination
Simulator.py
├── main.py
├── maxHeap.py
├── heapSort.py
├── Simulator.py
├── README.md
├── requirements.txt
└── User Guide.pdf
Python 3.13+ (tkinter bundled by default)
No external pip packages required
-
Clone/Download repository
-
Run console version (python main.py)
-
Run GUI simulator (python Simulator.py)
Concosle version included two main options:
Operation Description Example Input
Heap Sort Full algorithm execution with step prints 18,17,24,20,26,19,13
Max-Heap Interactive heap operations Build → Add → Extract → Remove
Sample workflow:
1. Heap-Sort → Enter: "16,14,10,8,7,9,3,2,4,1"
2. See:
"0. Initial array",
"1a. max-heap of n elements",
"2. Repeatedly move max to end"
3. Max-Heap → Build → Add(15) → Extract Max → Remove(10) → Sort current heap
The two main options of max-Heap and heap Sort were put into two tabs for data tree visualization:
Tab Features
Max-Heap Build heap, Add/Remove/Extract, Tree canvas, Operation log
Heap Sort Step-by-step animation, Prev/Next navigation, Tree + trace log
1. Heap tree with root in blue and showing the parent-child relationships
2. Step counters and operation logs (for better understanding of time complexity)
3. Copy-paste array support between console/GUI
Heapify Up: New element bubbles up to correct position
Heapify Down: Root vacancy bubbles down largest child path
Remove arbitrary: Replace with last + heapify up/down
Created by IHL in April 2026 for COMP 8090SEF - Data Structures, Algorithms And Problem Solving Data Structures, Algorithms
Feel free to use for educational purposes.
- Simulator
- Console