Skip to content

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

📊 Sorting Visualizer

🚀 Interactive Sorting Algorithm Visualizer built with Python & Tkinter

A desktop application that visualizes popular sorting algorithms through animated bar graphs.

The project is designed to make Data Structures & Algorithms (DSA) easier to understand by allowing users to watch sorting oprations step by step.

Python Tkinter


📖 Overview

Sorting Visualizer is a graphical desktop application developed using Python and Tkinter.

Instead of simply displaying the final sorted result, the application represents array elements as vertical bars and updates the graph while the sorting algorithm is running.

The project combines Python programming, GUI development, Data Structures, Algorithms, recursion, and algorithm visualization in one application.


✨ Features

✅ Interactive graphical user interface built with Tkinter

✅ Generate random arrays

✅ Enter custom array manually

✅ Five implemented sorting algorithms

✅ Adjustable visualization speed

✅ Real-time bar graph visualization

✅ Color-based sorting visualization

✅ Reset visualization anytime

✅ Detect already sorted arrays

✅ Displays the sorted result after completion

✅ Close the application directly from the GUI


🧠 Implemented Algorithms

Algorithm Time Complexity Space Complexity
Bubble Sort O(n²) O(1)
Selection Sort O(n²) O(1)
Insertion Sort O(n²) O(1)
Merge Sort O(n log n) O(n)
Quick Sort O(n log n) Average O(log n)

🔍 Algorithm Descriptions

🔵 Bubble Sort

Bubble Sort repeatedly compares adjacent elements and swaps them when they are in the wrong order.

🟣 Selection Sort

Selection Sort searches for the smallest element in the unsorted portion of the array and places it in its correct position.

🟢 Insertion Sort

Insertion Sort builds the sorted portion of the array one element at a time.

It works similarly to arranging playing cards in your hand.

🟡 Merge Sort

Merge Sort is a Divide and Conquer algorithm.

It recursively divides the array into smaller parts and then merges the sorted parts together.

🔴 Quick Sort

Quick Sort is another Divide and Conquer algorithm.

The implementation selects a pivot and partitions the array around it.

🎮 Application Controls

🎲 Create Random Array

Click Create Array to generate a random array.

The current implementation generates:

Array Size: 20

Minimum Value: 0

Maximum Value: 100

Example:

[42, 17, 89, 31, 76, 5, 63, 28, ...]

⌨️ Custom Input

Users can manually enter numbers separated by commas.

Example:

12,5,8,20,3,9,15

After entering the values, click:

Enter Input

The array will then be displayed on the visualization canvas.


🧠 Select Sorting Algorithms

Choose one of the available algorithms:

  • Merge Sort
  • Quick Sort
  • Bubble Sort
  • Selection Sort
  • Insertion Sort

⚡ Speed Control

Three visualization speeds are available:

Speed Description
⚡ Fast Quickly displays the sorting process
🚶 Medium Balanced visualization speed
🐢 Slow Slower animation for learning

For understanding the algorithm step by step, Slow mode is recommended.


▶️ Sort

After selecting an algorithm and preparing the array, click:

Sort

The application starts the selected sorting algorithm and updates the visualization during execution.


🔄 Reset Graph

Click:

Reset Graph

to clear the current array and visualization canvas.


❌ Close

Click:

Close

to exit the application.


🎨 Visualization

The array represented using vertical bars.

The height of each bar corresponds to its value.

Different colors represent different stages during sorting.

Color Meaning
🔵 Blue Default array elements
🟡 Yellow Active element / comparison
🔴 Red Another active element / sorting operation

Colors can vary slightly between algorithms because each algorithm has its own visualization logic.


🛠 Technologies Used

Programming Languages

Python 3

GUI

Tkinter

ttk

Standard Libraries

random

time

tkinter.messagebox

No external Python packages are required for the current version.


📂 Project Structure

Sorting-Visualizer/
│
├── sorting_visualizer.py
|
└── README.md

💻 Requirements

Before running the project, make sure you have:

  • Python 3.x

  • Tkinter

Tkinter is included with most standard Python installations.

You can test Tkinter with:

python -m tkinter

💡 Learning Objectives

This project helps understand:

  • Sorting algorithms
  • Algorithm visualization
  • Recursion
  • Divide and Conquer
  • GUI Programming
  • Event-driven Programming
  • Python Tkinter

🚀 Future Improvements

Planned improvements include:

⬜ Heap Sort

⬜ Radix Sort

⬜ Counting Sort

⬜ Shell Sort

⬜ Array size slider

⬜ Pause / Resume

⬜ Step-by-step execution

⬜ Dark Mode

⬜ Improved UI/UX

⬜ Complexity comparison charts

⬜ Execution-time measurement

⬜ Number of comparisons

⬜ Number of swaps

⬜ Statistics dashboard

⬜ Sound effects

⬜ Algorithm explanation panel

⬜ Better animation system


⭐ Support

If you found this project helpful, consider giving it a ⭐ on GitHub.

It helps others discover the project and motivates future development.


About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages