Skip to content

aliminagar/sorting-algorithm-visualize

Repository files navigation

Sorting Algorithm Visualizer 🎨

An interactive web application that visualizes various sorting algorithms in real-time. Watch how different algorithms sort data with animated visual representations.

Sorting Visualizer Demo

🚀 Features

  • Multiple Sorting Algorithms: Visualize different sorting algorithms including:

    • Bubble Sort
    • Quick Sort
    • Merge Sort
    • Insertion Sort
    • Selection Sort
  • Adjustable Array Size: Change the number of elements to sort (10-1000)

  • Random Sample Generation: Generate new random arrays with one click

  • Real-time Visualization: Watch the sorting process step-by-step

  • Responsive Design: Works on desktop and mobile devices

  • Color-coded Animations: Different colors represent different stages of sorting

🛠️ Technologies Used

  • React.js - Frontend framework
  • JavaScript (ES6+) - Programming language
  • HTML5 & CSS3 - Structure and styling
  • Node.js & npm - Package management

📦 Installation

  1. Clone the repository:
git clone https://github.com/aliminagar/sorting-algorithm-visualizer.git
  1. Navigate to the project directory:
cd sorting-algorithm-visualizer
  1. Install dependencies:
npm install
  1. Start the development server:
npm start
  1. Open http://localhost:3000 in your browser

💻 Usage

  1. Select a sorting algorithm from the dropdown menu
  2. Adjust the array size using the number input (default: 500)
  3. Click "Generate Sample" to create a new random array
  4. Click "Sort" to watch the algorithm visualize the sorting process
  5. Experiment with different algorithms and array sizes to compare performance

🎯 Learning Objectives

This project helped me understand:

  • How different sorting algorithms work under the hood
  • Algorithm time complexity (O(n²), O(n log n), etc.)
  • React component architecture and state management
  • Asynchronous JavaScript and animation timing
  • Breaking down complex problems into smaller components

🔮 Future Improvements

  • Add algorithm speed control (slow, medium, fast)
  • Display time and space complexity information
  • Add comparison counter to show number of comparisons
  • Include more algorithms (Heap Sort, Radix Sort, etc.)
  • Add dark/light theme toggle
  • Show algorithm pseudocode during visualization
  • Add sound effects for each comparison/swap

📊 Algorithm Complexity

Algorithm Best Case Average Case Worst Case Space Complexity
Bubble Sort O(n) O(n²) O(n²) O(1)
Quick Sort O(n log n) O(n log n) O(n²) O(log n)
Merge Sort O(n log n) O(n log n) O(n log n) O(n)
Insertion Sort O(n) O(n²) O(n²) O(1)
Selection Sort O(n²) O(n²) O(n²) O(1)

🤝 Contributing

Contributions are welcome! Feel free to:

  1. Fork the project
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

📝 License

This project is licensed under the MIT License - see the LICENSE file for details.

👤 Author

Alireza Minagar

🙏 Acknowledgments

  • Thanks to the React community for excellent documentation
  • Built as a learning project to deepen understanding of algorithms and data structures

⭐ If you found this project helpful, please consider giving it a star!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published