Skip to content

Commit 7d52599

Browse files
committed
handle edge case
1 parent 2f16376 commit 7d52599

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

2-selection_sort.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ void selection_sort(int *array, size_t size)
1212
size_t upperFor, innerFor, lowerInt_index;
1313
int lowerInt;
1414

15-
if (size < 2 || array == NULL)
15+
if (size < 2)
1616
return;
1717

1818
for (upperFor = 0; upperFor < size - 2; upperFor++)
@@ -27,7 +27,7 @@ void selection_sort(int *array, size_t size)
2727
lowerInt_index = innerFor;
2828
}
2929
}
30-
if (array[upperFor] != lowerInt)
30+
if (upperFor != lowerInt_index)
3131
{
3232
array[lowerInt_index] = array[upperFor];
3333
array[upperFor] = lowerInt;

0 commit comments

Comments
 (0)