Quick Sort Demonstration with 5 Numbers
Quick Sort Demonstration with 8 Numbers
Overview
A step-by-step visual demonstration of the quick sort algorithm on an array of 8 integers. The animation shows pivot selection, partitioning, recursive sorting of subarrays, and the final sorted order. The key takeaway is understanding how partitioning and recursion combine to sort an array.
Phases
| # | Phase Name | Duration | Description |
|---|---|---|---|
| 1 | Intro | ~3s | Display an unsorted array of 8 bars (e.g., heights representing values [3, 1, 4, 5, 2, 8, 6, 7]) with numeric labels above them. A title appears briefly: "Quick Sort". |
| 2 | Choose Pivot | ~3s | Highlight the last element (value 7) as the pivot (e.g., change its color to blue). Show a small label "Pivot" near it. |
| 3 | Partition | ~15s | Initialize two pointers: i (left) at the first element, j (right) moving leftward. Animate comparisons: move j left until finding an element < pivot, then move i right until finding an element > pivot, then swap those elements. Continue until i and j cross, then swap pivot into correct position. Highlight each swap with a brief flash or color change. After partition, the pivot is in its final position (colored green). |
| 4 | Recursive Sort | ~15s | Indicate that the left subarray (elements left of pivot) and right subarray (elements right of pivot) need sorting. Recurse by repeating phases 2-3 on each subarray, but with a smaller visual focus (e.g., dim non-focus elements). Show the recursive steps sequentially: first sort left subarray (size 3), then right subarray (size 4). Use different colors for the current subarray regions. |
| 5 | Completion | ~3s | All bars become green and a label "Sorted!" appears. The final array is displayed in ascending order: [1, 2, 3, 4, 5, 6, 7, 8]. |
Layout
┌─────────────────────────────────────────────┐
│ │
│ MAIN (array bars) │
│ │
├─────────────────────────────────────────────┤
│ Caption (step label or key information) │
└─────────────────────────────────────────────┘
Area Descriptions
| Area | Content | Notes |
|---|---|---|
| Main | Vertical bars representing array elements, with numeric labels above each bar. Pivot, pointers, and swapped elements are highlighted with color changes (e.g., blue for pivot, red for compared/swapped, orange for swapped, green for sorted). | Primary focus; bars are evenly spaced. |
| Caption | Short step label (e.g., "Pivot: 7", "Partitioning...", "Sorting left subarray") | Persistent at bottom; updates each phase. |
Notes
- Use a simple array [3, 1, 4, 5, 2, 8, 6, 7] (values from 1 to 8) for clarity.
- Elements: bars with heights proportional to values.
- Pointers: small arrows or markers below the bars for i and j during partitioning.
- Color scheme: default gray, pivot blue, compared/selected red, swapped orange, final sorted green.
- Keep transitions smooth (duration ~0.5s for highlights, ~1s for swaps).
- No code or equations; purely visual demonstration.
- Ensure total animation time stays under 40 seconds.
Créé par
Description
An animated step-by-step visualization of the quick sort algorithm on a small array of five integers. It shows pivot selection, partitioning with pointer swaps, recursive sorting of subarrays, and the final sorted order, using color-coded bars to represent array elements.
Date de création
Jun 8, 2026, 06:15 AM
Durée
0:33
Tags
quick-sortsorting-algorithmsalgorithm-visualizationcomputer-science