An interactive, real-time visualization tool for understanding the QuickSort algorithm. Watch how QuickSort partitions, compares, and sorts arrays step-by-step with detailed animations and multilingual support.
- Step-by-step visualization of the QuickSort algorithm
- Real-time animations showing comparisons, swaps, and partitioning
- Color-coded elements:
- ๐ต Blue: Current partition boundaries
- ๐ก Yellow: Pivot element
- ๐ Orange: Elements being compared
- ๐ด Red: Elements being swapped
- ๐ข Green: Sorted elements
- Play/Pause: Start or pause the sorting animation
- Step Navigation: Move forward or backward through each step
- Adjustable Speed: Control animation speed with a slider (slow to fast)
- Reset: Return to the initial state at any time
- Multiple Pivot Selection Strategies:
- Last Element (default)
- First Element
- Middle Element
- Random Element
- Custom Array Input: Enter your own numbers to sort
- Random Array Generation: Generate random arrays of customizable size (2-50 elements)
- Real-time metrics:
- Number of comparisons performed
- Number of swaps executed
- Current step / Total steps counter
- English (EN)
- Romanian (RO)
- Seamless language switching with preserved state
- Light Mode: Clean, bright interface
- Dark Mode: Eye-friendly dark theme
- System preference detection
- Persistent theme selection
- Fully responsive layout for desktop, tablet, and mobile
- Optimized visualizations for all screen sizes
- Touch-friendly controls
- Step-by-step algorithm execution logs
- Descriptions of each operation
- Localized log messages
- Node.js 20.x or higher
- npm, yarn, pnpm, or bun
- Clone the repository:
git clone https://github.com/k6w/quicksort-visualizer.git
cd quicksort-visualizer- Install dependencies:
npm install
# or
yarn install
# or
pnpm install- Run the development server:
npm run dev
# or
yarn dev
# or
pnpm dev- Open http://localhost:3000 in your browser.
quicksort-visualizer/
โโโ app/ # Next.js app directory
โ โโโ globals.css # Global styles
โ โโโ layout.tsx # Root layout
โ โโโ page.tsx # Main page
โโโ components/ # React components
โ โโโ AdvancedSettings.tsx # Pivot strategy selector
โ โโโ ControlPanel.tsx # Playback controls
โ โโโ InputPanel.tsx # Array input interface
โ โโโ LanguageToggle.tsx # Language switcher
โ โโโ LogPanel.tsx # Algorithm execution logs
โ โโโ ThemeToggle.tsx # Light/dark mode toggle
โ โโโ Visualizer.tsx # Main visualization component
โโโ lib/ # Utilities and core logic
โ โโโ algorithms/
โ โ โโโ quicksort.ts # QuickSort implementation
โ โโโ contexts/
โ โ โโโ LanguageContext.tsx # i18n context
โ โ โโโ ThemeContext.tsx # Theme context
โ โโโ i18n.ts # Translation definitions
โ โโโ utils.ts # Utility functions
โโโ public/ # Static assets
โโโ [config files] # TypeScript, ESLint, etc.
-
Enter an Array:
- Type numbers separated by commas or spaces
- Or click "Generate Random" for a random array
-
Configure Settings (Optional):
- Choose a pivot selection strategy
- Adjust animation speed
-
Start Visualization:
- Click "Start" to begin the sorting animation
- Use "Pause" to stop at any step
- Navigate with "Next Step" / "Previous Step" for detailed examination
-
Observe:
- Watch the color-coded bars change as the algorithm executes
- Read the log panel for detailed step descriptions
- Monitor statistics for algorithm performance
- Next.js 16 - React framework with App Router
- React 19 - UI library
- TypeScript 5 - Type safety
- TailwindCSS 4 - Utility-first CSS
- Lucide React - Icon library
- class-variance-authority - Component variants
The QuickSort implementation features:
- Configurable pivot selection (first, last, middle, random)
- Detailed step tracking for visualization
- Performance metrics (comparisons and swaps)
- Partition-based sorting with visual boundaries
- Type-safe implementation with full TypeScript support
Edit lib/i18n.ts to add new translations:
export const translations = {
// ... existing languages
es: {
title: 'Visualizador QuickSort',
// ... other translations
}
};Colors are defined using Tailwind CSS variables in app/globals.css. Customize the theme by adjusting CSS variables.
npm run build
npm startThe optimized production build will be created in the .next directory.
This project can be easily deployed to:
Contributions are welcome! Feel free to:
- Report bugs
- Suggest new features
- Submit pull requests
- Improve documentation
This project is open source and available under the MIT License.
k6w
- GitHub: @k6w
- Built with modern web technologies
- Inspired by the need to understand sorting algorithms visually
- Educational tool for computer science students and enthusiasts