This project is an interactive sorting algorithm visualizer built in Java Swing.
It demonstrates the internal mechanics of classic sorting techniques through real-time animation, step-by-step debugging, and mathematical analysis. The tool is designed as a learning aid for Data Structures and Algorithms, allowing users to pause execution, rewind states, and observe how data moves during sorting in real time.
This project was developed using Java, with the graphical interface implemented using Java Swing and rendering handled through AWT’s Graphics2D API. The application visualizes multiple sorting algorithms including Bubble, Selection, Insertion, Merge, Quick, Heap, and Shell Sort using a custom animation engine based on repaint cycles and timed execution delays. A snapshot-based state management system was designed to enable pause, step-forward, and step-backward debugging of algorithm execution. The system follows an event-driven architecture with multithreaded sorting execution to maintain UI responsiveness. Object-oriented design principles were used to model visual elements, algorithm states, and interaction logic, while real-time operation tracking provides analytical insights into comparisons and data movements.
-
Snapshot Debugger
Records every array state. Pause the sort and scrub through history using ← Previous and Next →. -
Fluid Animation Engine
High-performanceGraphics2Drendering with anti-aliasing and rounded bar geometry. -
Live Operation Tracking
Real-time comparison + move counters. -
Theory Panel
Displays time complexity, recurrence equations, evaluated formulas based on array size, and color legend. -
Deep Time Analysis
Estimates actual CPU execution time vs. visualized delay scale. -
Thread-safe Control System
Monitor-based pause/resume/step execution.
| Algorithm | Best Case | Average Case | Worst Case |
|---|---|---|---|
| Bubble Sort | O(n) | O(n²) | O(n²) |
| Selection Sort | O(n²) | O(n²) | O(n²) |
| Insertion Sort | O(n) | O(n²) | O(n²) |
| Merge Sort | O(n log n) | O(n log n) | O(n log n) |
| Quick Sort | O(n log n) | O(n log n) | O(n²) |
| Heap Sort | O(n log n) | O(n log n) | O(n log n) |
| Shell Sort | depends on gap | ~O(n^(3/2)) | O(n²) |
- Select an algorithm
- Generate a dataset
- Start the sort
- Pause anytime to step backward/forward
- Resume from any snapshot
javac DSAVisualizer.java
java DSAVisualizerRequires Java 11+
