This project is a Java-based graphical visualizer for sorting algorithms. It allows users to visually observe how various sorting algorithms work, thanks to an intuitive GUI and a flexible strategy-based architecture.
The application generates a random array of integers and displays it in a graphical window. It then sorts the array using a specified sorting algorithm, updating the visualization in real time. The project is built using Java Swing and employs design patterns such as Strategy and Observer for modular and extensible logic. The UML is in src/UML.png
.
- Visual representation of sorting steps.
- Pluggable sorting algorithms (easily extendable).
- Adjustable array length and sorting speed.
- Intuitive GUI using
MainFrame
andArrayViewerPanel
.
The following sorting strategies are currently implemented:
SelectionSortStrategy
QuickSortStrategy
MergeSortStrategy
InsertionSortStrategy
HeapSortStrategy
BubbleSortStrategy
BogoSortStrategy
(for educational/demonstrative purposes)
Thanks to the Strategy design pattern is really easy to implement other sorting algoritms.
- Java Development Kit (JDK) 8 or higher.
- Java-compatible IDE (e.g., IntelliJ IDEA, Eclipse) or CLI tools.
- Clone or download the repository.
- Open the project in your Java IDE.
- Navigate to the
Main.java
file. - (Optional) Choose the sorting algorithm by setting the strategy:
private static SortStrategy strategy = new MergeSortStrategy(); // Change as needed
- Run the
Main
class