Skip to content

ecdataview-sys/Task-2---Max-Heap-Heap-Sort

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Task-2 - Max-Heap & Heap Sort

Task 2: Data Structure: max-heap & Algorithm: heap sort

Project Overview

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.

  1. Console - with detailed step-by-step print statements

    main.py

    maxHeap.py

    heapSort.py

  2. GUI Simulator - with data tree visualization, operation logs and step-by-step heap sort anmination

    Simulator.py

Reporsitory Structure

├── main.py

├── maxHeap.py

├── heapSort.py

├── Simulator.py

├── README.md

├── requirements.txt

└── User Guide.pdf

Prerequisites

Python 3.13+ (tkinter bundled by default)

No external pip packages required

  1. Clone/Download repository

  2. Run console version (python main.py)

  3. Run GUI simulator (python Simulator.py)

Console Version (main.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

GUI simulator (Simulator.py)

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

Key visualizations

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

Key algorithms

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

License

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.

Screen Shot

  1. Simulator
image image image image
  1. Console
image image image image image

YouTube Introduction Video

Watch the demo on YouTube

About

Task 2: Data Structure: max-heap & Algorithm: heap sort

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages