You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
description: `Bubble sort goes through every element in the array comparing the current item to the one after it.
11
+
If the current is greater than the next we swap them. We repeat this until were done. The time complexity of this is
12
+
O(N^2)`,
13
+
},
14
+
{
15
+
name: "Merge Sort",
16
+
description: `In merge sort we split the array recursively. The idea is that we want to solve a smaller version of the problem so we break it down
17
+
to its simplest form. This would be two items that we compare which merge into correct order. Then we repeat again until fully merged. The time complexity of this is
18
+
O(N LOG(N))`,
19
+
},
20
+
{
21
+
name: "Selection Sort",
22
+
description: `In selection sort we set a min (first item by default). We itterate the list looking for a smaller min.
23
+
If we get to the end of the list without finding another min we swap it. We continue this until all iterrations are done.
24
+
The time complexity of this is
25
+
O(N^2)`,
26
+
},
27
+
{
28
+
name: "Insertion Sort",
29
+
description: `Here we itterate through the array with a right pointer. If it the item before the right pointer is greater than we pass it back and swap it.
30
+
We continue this until it the right pointer is in the correct position. The time complexity of this is
description: `Bubble sort goes through every element in the array comparing the current item to the one after it.
21
-
If the current is greater than the next we swap them. We repeat this until were done. The time complexity of this is
22
-
O(N^2)`,
23
-
},
24
-
{
25
-
name: "Merge Sort",
26
-
description: `In merge sort we split the array recursively. The idea is that we want to solve a smaller version of the problem so we break it down
27
-
to its simplest form. This would be two items that we compare which merge into correct order. Then we repeat again until fully merged. The time complexity of this is
28
-
O(N LOG(N))`,
29
-
},
30
-
{
31
-
name: "Selection Sort",
32
-
description: `In selection sort we set a min (first item by default). We itterate the list looking for a smaller min.
33
-
If we get to the end of the list without finding another min we swap it. We continue this until all iterrations are done.
34
-
The time complexity of this is
35
-
O(N^2)`,
36
-
},
37
-
{
38
-
name: "Insertion Sort",
39
-
description: `Here we itterate through the array with a right pointer. If it the item before the right pointer is greater than we pass it back and swap it.
40
-
We continue this until it the right pointer is in the correct position. The time complexity of this is
41
-
O(N^2) `,
42
-
},
43
-
];
44
13
45
14
constArrays=()=>{
46
15
const[array,setArray]=useState([]);
@@ -59,7 +28,7 @@ const Arrays = () => {
59
28
};
60
29
61
30
// Function to start sorting visuals
62
-
conststartSorting=(animations)=>{
31
+
conststartSorting=(animations: any[])=>{
63
32
// Function to handle the animations for sorting algorithms
64
33
constarrayBars=document.getElementsByClassName("array-bar");// select the array bars html
65
34
letcurrent_animation={compare: []};// we compare this to the first animation
0 commit comments