Skip to content

Commit 05c090f

Browse files
committed
Increase test size to 1,000 ints
1 parent 4abbf9a commit 05c090f

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

ShakerSort/Class1.cs

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ namespace SortingAlgos
44
{
55
public class ShakerSort
66
{
7+
private static bool swapped = true;
8+
79
public static void Sort(int[] input)
810
{
911
int len = input.Length;
10-
bool swapped = true;
1112

12-
while (swapped == true)
13+
while (swapped)
1314
{
1415
swapped = false;
1516

@@ -24,12 +25,8 @@ public static void Sort(int[] input)
2425
}
2526
}
2627

27-
if (swapped == false)
28-
{
29-
return;
30-
}
31-
32-
swapped = false;
28+
// If nothing was changed, return
29+
if (swapped == false) return;
3330

3431
for (int i = len - 2; i > 0; i--)
3532
{
@@ -41,11 +38,6 @@ public static void Sort(int[] input)
4138
swapped = true;
4239
}
4340
}
44-
45-
if (swapped == false)
46-
{
47-
return;
48-
}
4941
}
5042
}
5143
}

0 commit comments

Comments
 (0)