How anunayreddy22/sorting-visualizer works
1. This repository is a single-purpose Java desktop application: a sorting visualizer. The architecture is centered on a GUI that animates sorting algorithms step by step for educational use.
2. Entry and orchestration appear to live in Visualizer/SortingVisualizer.java. This is likely the application bootstrap and the coordination point that wires the frame, the array data, the selected algorithm, and the animation lifecycle together.
3. The UI boundary is Visualizer/VisualizerFrame.java. This class is the presentation layer: it presents the controls the README mentions, such as algorithm selection and speed adjustment, and renders the array state during sorting.
4. The algorithm layer is isolated under Visualizer/Sorts/. Each file represents one sorting strategy: BubbleSort, SelectionSort, InsertionSort, MergeSort, RadixSort, ShellSort, GnomeSort, and QuandrixSort. This separation makes the system easy to diagram as “UI” → “algorithm implementation.”
5. The key data flow is: the UI or main controller creates an input array, passes it to the chosen sort implementation, and the sort updates the array state while the frame repaints the visual bars/markers. The animation is therefore driven by algorithm progress, not by a separate backend service.
6. Real-time visualization is the core coupling between the UI and sorting logic. The sort classes are likely instrumented to expose intermediate swaps or comparisons so the frame can redraw after each meaningful step instead of only showing the final result.
7. Speed control is a distinct interaction boundary in the UI. It likely influences timing between animation frames or pauses inside the sorting loop, which means it affects execution pacing rather than the sorting outcome itself.
8. The repository does not show a network layer, persistence layer, or external service integration. This is a self-contained local GUI program, so the architectural diagram should stay focused on in-process components only.
9. There is a clear separation between reusable algorithm code and visual presentation code. That makes the sort classes portable, while the frame and controller are specific to the visualization experience.
10. For a diagram, the main boxes are: application bootstrap, visual frame/controls, array state/animation engine, and the individual sorting algorithm modules. The arrows should show user input flowing into the frame, algorithm choice flowing into the controller, and array mutations flowing back to the renderer during execution.
Main entry points: SortingVisualizer.java Sorting app · VisualizerFrame.java Visualizer frame · BubbleSort.java Bubble sort · SelectionSort.java Selection sort
Components 14
Visualizer
Bootstrap, frame, and runtime coordination
- Sorting app · Starts the application and coordinates sorting runs
Sorting-Visualizer/Visualizer/SortingVisualizer.java - Visualizer frame · Main window for controls and drawing
Sorting-Visualizer/Visualizer/VisualizerFrame.java - Array state · In-memory values being sorted and rendered
- Render loop · Redraws the bars and step-by-step progress
- Speed control · Adjusts animation pacing
- Algo picker · Chooses which sorting strategy to run
Sorting algorithms
Algorithm implementations used by the visualizer
- Bubble sort · Bubble sort implementation
Sorting-Visualizer/Visualizer/Sorts/BubbleSort.java - Selection sort · Selection sort implementation
Sorting-Visualizer/Visualizer/Sorts/SelectionSort.java - Insertion sort · Insertion sort implementation
Sorting-Visualizer/Visualizer/Sorts/InsertionSort.java - Merge sort · Merge sort implementation
Sorting-Visualizer/Visualizer/Sorts/MergeSort.java - Radix sort · Radix sort implementation
Sorting-Visualizer/Visualizer/Sorts/RadixSort.java - Shell sort · Shell sort implementation
Sorting-Visualizer/Visualizer/Sorts/ShellSort.java - Gnome sort · Gnome sort implementation
Sorting-Visualizer/Visualizer/Sorts/GnomeSort.java - Quandrix sort · Quandrix sort implementation
Sorting-Visualizer/Visualizer/Sorts/QuandrixSort.java
Connections 26
- Sorting app → Visualizer frame: creates · Bootstraps the UI window
- Sorting app → Array state: initializes · Builds the array to be visualized
- Sorting app → Algo picker: wires · Connects algorithm choice into runtime
- Sorting app → Speed control: wires · Connects pacing control into runtime
- Sorting app → Render loop: drives · Starts and coordinates animation updates
- Visualizer frame → Algo picker: hosts · Presents algorithm selection controls
- Visualizer frame → Speed control: hosts · Presents speed adjustment controls
- Visualizer frame → Render loop: paints · Draws the current array state
- Array state → Render loop: feeds · Current values are rendered as bars/markers
- Algo picker → Bubble sort: routes to · Dispatches to the chosen sort implementation
- Algo picker → Selection sort: routes to · Dispatches to the chosen sort implementation
- Algo picker → Insertion sort: routes to · Dispatches to the chosen sort implementation
- Algo picker → Merge sort: routes to · Dispatches to the chosen sort implementation
- Algo picker → Radix sort: routes to · Dispatches to the chosen sort implementation
- Algo picker → Shell sort: routes to · Dispatches to the chosen sort implementation
- Algo picker → Gnome sort: routes to · Dispatches to the chosen sort implementation
- Algo picker → Quandrix sort: routes to · Dispatches to the chosen sort implementation
- Bubble sort → Array state: mutates · Updates the shared array during sorting steps
- Selection sort → Array state: mutates · Updates the shared array during sorting steps
- Insertion sort → Array state: mutates · Updates the shared array during sorting steps
- Merge sort → Array state: mutates · Updates the shared array during sorting steps
- Radix sort → Array state: mutates · Updates the shared array during sorting steps
- Shell sort → Array state: mutates · Updates the shared array during sorting steps
- Gnome sort → Array state: mutates · Updates the shared array during sorting steps
- Quandrix sort → Array state: mutates · Updates the shared array during sorting steps
- Speed control → Render loop: paces · Controls delay between visual steps