Skip to content

Visualize Selection Sort with C++ (graphics.h) and Python (matplotlib). Watch array elements transform in real-time through colorful animations and dynamic updates. Great for understanding sorting logic visually!

Notifications You must be signed in to change notification settings

dvanhu/selection-sort-visualizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Selection Sort Visualization 🎨

A graphical demonstration of the Selection Sort algorithm using graphics.h in C++.

📸 Screenshots

Visualization:

Input Visualization: image Unsorted Array

Output Visualization: image Sorted Array

📋 Description

This project visualizes how Selection Sort works by drawing vertical lines to represent array elements and highlighting transitions in color:

  • White lines: array elements (height = value)
  • Green lines: currently selected minimum element
  • Real-time swapping animations using swap_colors() function

🧠 Algorithm Logic

Selection Sort repeatedly:

  1. Finds the minimum element in the unsorted section
  2. Swaps it with the first unsorted element
  3. Updates the visualization on every change

🛠️ Tools & Libraries

  • C++
  • graphics.h (Turbo C++ or WinBGIm)

▶️ How to Run

  1. Install Turbo C++ or any graphics.h compatible environment (like WinBGIm)
  2. Compile using:
    g++ selection_sort.cpp -lbgi -lgdi32 -lcomdlg32 -luuid -loleaut32 -lole32
    

🐍 Python Version (Matplotlib)

This version visualizes Selection Sort using Python and matplotlib. It dynamically updates the bar chart after each swap for a clear view of sorting progress.

📦 Requirements

Install dependencies with:

pip install matplotlib

About

Visualize Selection Sort with C++ (graphics.h) and Python (matplotlib). Watch array elements transform in real-time through colorful animations and dynamic updates. Great for understanding sorting logic visually!

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published