An interactive, educational web application that visualizes different sorting algorithms in action. Perfect for students learning Data Structures and Algorithms (DSA).
The DSA Simulator allows students to explore how different sorting algorithms work through animated visualizations. Simply input the array size, select a sorting algorithm, and watch as the visualizer demonstrates each step of the sorting process.
- 5 Sorting Algorithms: Bubble Sort, Selection Sort, Insertion Sort, Merge Sort, and Quick Sort
- Real-time Visualization: Watch each algorithm in action with smooth animations
- Speed Control: Adjust visualization speed from 10% to 500%
- Pause/Resume: Pause the animation to analyze specific steps
- Performance Metrics: Track comparisons, swaps, and iterations
- Customizable Array Size: Test with arrays from 5 to 150 elements
- Responsive Design: Works on desktop and tablet devices
- No Coding Required: Pure visual learning experience
- Time Complexity: O(n²)
- Best for: Understanding basic sorting concepts
- Characteristics: Repeatedly compares adjacent elements and swaps them if in wrong order
- Time Complexity: O(n²)
- Best for: Understanding selection-based sorting
- Characteristics: Finds minimum element and places it at beginning each iteration
- Time Complexity: O(n²)
- Best for: Nearly sorted data
- Characteristics: Inserts each element into its correct position in sorted portion
- Time Complexity: O(n log n)
- Best for: Divide-and-conquer approach
- Characteristics: Divides array and merges sorted subarrays
- Time Complexity: O(n log n) average
- Best for: General-purpose sorting
- Characteristics: Uses pivot partitioning for efficient sorting
- Node.js (v14 or higher)
- npm or yarn
-
Clone the repository
git clone https://github.com/cmascar4/DSA_Simulator.git cd DSA_Simulator -
Install dependencies
npm install
-
Start the development server
npm start
The application will open at
http://localhost:3000 -
Build for production
npm build
- Select Algorithm: Choose from the dropdown menu (Bubble Sort, Selection Sort, etc.)
- Set Array Size: Use the slider to select how many numbers to sort (5-150)
- Adjust Speed: Control animation speed using the speed slider (10%-500%)
- Start Sorting: Click "Start Sorting" to begin the visualization
- Monitor Metrics: Watch real-time statistics:
- Comparisons: Number of element comparisons made
- Swaps: Number of element exchanges
- Iterations: Number of algorithm iterations
DSA_Simulator/
├── public/
│ └── index.html # Main HTML file
├── src/
│ ├── components/
│ │ ├── Controls.js # Control panel component
│ │ ├── Controls.css # Control styling
│ │ ├── Visualizer.js # Visualization component
│ │ └── Visualizer.css # Visualization styling
│ ├── algorithms/
│ │ └── sortingAlgorithms.js # Sorting algorithm implementations
│ ├── App.js # Main App component
│ ├── App.css # App styling
│ ├── index.js # React entry point
│ └── index.css # Global styles
├── package.json # Project dependencies
└── README.md # This file
- React 18: UI framework
- JavaScript ES6+: Programming language
- CSS3: Styling with animations
- HTML5: Markup
By using this simulator, students will:
- ✓ Understand how different sorting algorithms work step-by-step
- ✓ Compare algorithm efficiency through performance metrics
- ✓ Visualize the differences between O(n²) and O(n log n) algorithms
- ✓ See how pivot selection affects Quick Sort performance
- ✓ Analyze the merge process in Merge Sort
- ✓ Understand time complexity through real-world demonstration
- Classroom presentation tool for algorithm demonstrations
- Visual aid for explaining algorithm concepts
- Interactive learning experience that increases engagement
- Interactive learning without writing code
- Immediate visual feedback on algorithm behavior
- Ability to experiment with different array sizes
- Performance metrics to understand efficiency
- Start Simple: Begin with Bubble Sort to understand basic concepts
- Compare: Run the same array with different algorithms to see efficiency differences
- Vary Array Sizes: Test with small and large arrays to see scaling effects
- Slow Down: Use lower speeds to carefully observe each step
- Repeat: Run the same algorithm multiple times to reinforce understanding
- Small Arrays (5-50): All algorithms perform noticeably fast
- Medium Arrays (50-100): Quadratic algorithms show visible slowdown
- Large Arrays (100-150): Merge Sort and Quick Sort demonstrate clear advantages
- Chrome (recommended)
- Firefox
- Safari
- Edge
- Mobile browsers (iOS Safari, Chrome Mobile)
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
Future enhancements:
- Counting Sort and Radix Sort
- Heap Sort implementation
- Algorithm comparison mode
- Sound effects for comparisons/swaps
- Dark mode theme
- Code snippet display for each algorithm
- Detailed algorithm explanation panels
- Save/replay sorting visualizations
For issues, questions, or suggestions, please open an issue on GitHub or contact the maintainers.
Happy Learning! 🚀