Skip to content

Commit 1400e7c

Browse files
committed
fix a bug in quicksort
1 parent 0ca2bc9 commit 1400e7c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

include/quick_sort.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ namespace alg {
7474
quicksort(list, begin, pivot_idx-1);
7575
quicksort(list, pivot_idx+1, end);
7676
} else if ( begin + 1 == end) {
77-
if (list[begin + 1] > list[end])
78-
swap(list[begin + 1], list[end]);
77+
if (list[begin] > list[end])
78+
swap(list[begin], list[end]);
7979
}
8080
}
8181
}

0 commit comments

Comments
 (0)