This project is a React-based web application that visualizes various sorting algorithms. It provides an interactive way to understand how different sorting algorithms work by animating the sorting process on a set of randomly generated bars.
- Visualize 6 different sorting algorithms:
- Merge Sort
- Quick Sort
- Heap Sort
- Bubble Sort
- Selection Sort
- Insertion Sort
- Generate new random arrays
- Adjust the size of the array and sorting speed
- React.js
- JavaScript (ES6+)
- CSS3
SortingVisualizer.jsx: Main component that renders the sorting visualizationSortingAlgorithms.js: Contains implementations of all sorting algorithmsSortingVisualizer.css: Styles for the visualization component
- The application generates a random array of integers, represented as vertical bars.
- Users can select a sorting algorithm to visualize.
- The chosen algorithm sorts the array, with each comparison and swap animated on the screen.
- The animation uses color changes to highlight the elements being compared or swapped.
- Divide and conquer algorithm
- Time Complexity: O(n log n)
- Divide and conquer algorithm
- Time Complexity: Average O(n log n), Worst O(n^2)
- Comparison-based sorting algorithm
- Time Complexity: O(n log n)
- Simple comparison-based algorithm
- Time Complexity: O(n^2)
- In-place comparison sorting algorithm
- Time Complexity: O(n^2)
- Simple sorting algorithm
- Time Complexity: Average and Worst O(n^2), Best O(n)
- Clone the repository
- Navigate to the project directory
- Install dependencies: npm install
- Start the development server: npm start
- Open your browser and visit
http://localhost:3000
- Click "Generate New Array" to create a new set of bars
- Select a sorting algorithm button to start the visualization
- Watch the animation as the bars are sorted
You can adjust the following parameters in SortingVisualizer.jsx:
ANIMATION_SPEED_MS: Change the speed of the animationNUMBER_OF_ARRAY_BARS: Modify the number of bars (array size)
Contributions, issues, and feature requests are welcome. Feel free to check issues page if you want to contribute.