|
1 | 1 | import React, { useState, useEffect } from 'react';
|
2 |
| -import './BubbleSortVisualization.css'; |
| 2 | +import './BubbleSortVisualization.css'; |
3 | 3 |
|
4 | 4 | /**
|
5 | 5 | * BubbleSortVisualization Component
|
6 | 6 | * This component visualizes the Bubble Sort algorithm.
|
7 |
| - * |
| 7 | + * |
8 | 8 | * @returns {JSX.Element} The rendered component
|
9 | 9 | */
|
10 | 10 | const BubbleSortVisualization: React.FC = () => {
|
11 | 11 | // State to store the array of numbers to be sorted
|
12 | 12 | const [array, setArray] = useState<number[]>([]);
|
13 | 13 | // State to control the delay for visualization speed
|
14 |
| - const [delay, setDelay] = useState<number>(200); |
| 14 | + const [delay, setDelay] = useState<number>(200); |
15 | 15 | // State to indicate if sorting is in progress
|
16 |
| - const [isSorting, setIsSorting] = useState<boolean>(false); |
| 16 | + const [isSorting, setIsSorting] = useState<boolean>(false); |
17 | 17 | // State to store the indices of elements being compared
|
18 | 18 | const [comparingIndices, setComparingIndices] = useState<number[]>([]);
|
19 | 19 |
|
20 | 20 | // Effect to generate a new array when the component mounts
|
21 | 21 | useEffect(() => {
|
22 |
| - generateArray(); |
| 22 | + generateArray(); |
23 | 23 | }, []);
|
24 | 24 |
|
25 | 25 | // Effect to update the CSS transition duration when the delay changes
|
@@ -83,7 +83,7 @@ const BubbleSortVisualization: React.FC = () => {
|
83 | 83 | <button onClick={generateArray} disabled={isSorting}>Generate New Array</button>
|
84 | 84 | <br /><br />
|
85 | 85 | <p>
|
86 |
| - <strong>Instructions:</strong> Click the "Sort" button to visualize the Bubble Sort algorithm. You can also adjust the speed of the visualization using the slider. |
| 86 | + <strong>Instructions:</strong> Click the "Sort" button to visualize the Bubble Sort algorithm. You can also adjust the speed of the visualization using the slider. |
87 | 87 | </p>
|
88 | 88 | <div className="array-container">
|
89 | 89 | {array.map((value, index) => (
|
|
0 commit comments