Skip to content

Commit 04c04bf

Browse files
committed
Clean up SmoothSort implementation
- Remove redundant comments for cleaner code - Simplify heap sort implementation - Maintain functionality with cleaner structure
1 parent 76e1fd6 commit 04c04bf

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/main/java/com/thealgorithms/sorts/SmoothSort.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
/**
44
* Smooth Sort Algorithm Implementation
5-
* Uses a heap-based approach similar to heap sort but with better cache performance
5+
* Uses heap-based approach for reliable sorting performance
66
*
77
* @see <a href="https://en.wikipedia.org/wiki/Smoothsort">Smooth Sort Algorithm</a>
88
*/
@@ -21,12 +21,12 @@ public <T extends Comparable<T>> T[] sort(T[] array) {
2121
private <T extends Comparable<T>> void heapSort(T[] array) {
2222
int n = array.length;
2323

24-
// Build heap (rearrange array)
24+
// Build max heap
2525
for (int i = n / 2 - 1; i >= 0; i--) {
2626
heapify(array, n, i);
2727
}
2828

29-
// Extract elements from heap one by one
29+
// Extract elements from heap
3030
for (int i = n - 1; i > 0; i--) {
3131
SortUtils.swap(array, 0, i);
3232
heapify(array, i, 0);

0 commit comments

Comments
 (0)