Skip to content

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.

Notifications You must be signed in to change notification settings

k6w/quicksort-visualizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

6 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŽฏ QuickSort Visualizer

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.

Next.js React TypeScript TailwindCSS

โœจ Features

๐ŸŽฌ Visual Algorithm Execution

  • 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

๐ŸŽฎ Interactive Controls

  • 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

โš™๏ธ Advanced Configuration

  • 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)

๐Ÿ“Š Algorithm Statistics

  • Real-time metrics:
    • Number of comparisons performed
    • Number of swaps executed
    • Current step / Total steps counter

๐ŸŒ Multilingual Support

  • English (EN)
  • Romanian (RO)
  • Seamless language switching with preserved state

๐ŸŽจ Theme Support

  • Light Mode: Clean, bright interface
  • Dark Mode: Eye-friendly dark theme
  • System preference detection
  • Persistent theme selection

๐Ÿ“ฑ Responsive Design

  • Fully responsive layout for desktop, tablet, and mobile
  • Optimized visualizations for all screen sizes
  • Touch-friendly controls

๐Ÿ“ Detailed Logging

  • Step-by-step algorithm execution logs
  • Descriptions of each operation
  • Localized log messages

๐Ÿš€ Getting Started

Prerequisites

  • Node.js 20.x or higher
  • npm, yarn, pnpm, or bun

Installation

  1. Clone the repository:
git clone https://github.com/k6w/quicksort-visualizer.git
cd quicksort-visualizer
  1. Install dependencies:
npm install
# or
yarn install
# or
pnpm install
  1. Run the development server:
npm run dev
# or
yarn dev
# or
pnpm dev
  1. Open http://localhost:3000 in your browser.

๐Ÿ—๏ธ Project Structure

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.

๐ŸŽ“ How to Use

  1. Enter an Array:

    • Type numbers separated by commas or spaces
    • Or click "Generate Random" for a random array
  2. Configure Settings (Optional):

    • Choose a pivot selection strategy
    • Adjust animation speed
  3. 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
  4. Observe:

    • Watch the color-coded bars change as the algorithm executes
    • Read the log panel for detailed step descriptions
    • Monitor statistics for algorithm performance

๐Ÿ› ๏ธ Built With

๐Ÿง  Algorithm Implementation

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

๐ŸŽจ Customization

Adding New Languages

Edit lib/i18n.ts to add new translations:

export const translations = {
  // ... existing languages
  es: {
    title: 'Visualizador QuickSort',
    // ... other translations
  }
};

Modifying Color Scheme

Colors are defined using Tailwind CSS variables in app/globals.css. Customize the theme by adjusting CSS variables.

๐Ÿ“ฆ Build for Production

npm run build
npm start

The optimized production build will be created in the .next directory.

๐Ÿšข Deployment

This project can be easily deployed to:

Deploy on Vercel

Deploy with Vercel

๐Ÿค Contributing

Contributions are welcome! Feel free to:

  • Report bugs
  • Suggest new features
  • Submit pull requests
  • Improve documentation

๐Ÿ“„ License

This project is open source and available under the MIT License.

๐Ÿ‘จโ€๐Ÿ’ป Author

k6w

๐Ÿ™ Acknowledgments

  • Built with modern web technologies
  • Inspired by the need to understand sorting algorithms visually
  • Educational tool for computer science students and enthusiasts

Made with โค๏ธ for learning algorithms

About

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.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published