Skip to content

Commit 4f492ad

Browse files
committed
[ solved both logical error]
1 parent 3876364 commit 4f492ad

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

include/heap_sort.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ namespace algo {
2424

2525
if ( swpIdx != root ) {
2626
algo::swap( list[swpIdx], list[root] );
27+
root=swpIdx;
2728
} else {
2829
break;
2930
}
@@ -53,8 +54,9 @@ namespace algo {
5354
while ( high > 0 ) {
5455
algo::swap(list[high], list[0]);
5556
--high;
56-
__heapify(list, 0, high);
57+
5758
}
59+
__heapify(list, 0, high);
5860
}
5961
}
6062
#endif

0 commit comments

Comments
 (0)