Skip to content

Commit faf3eb6

Browse files
reformat the code
1 parent b85b01f commit faf3eb6

File tree

2 files changed

+0
-5
lines changed

2 files changed

+0
-5
lines changed

lib/features/sorting/heap/view_model/heap_sort_notifier.dart

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,10 @@ class HeapSortNotifier extends SortingNotifier {
4040
void heapSort() {
4141
int n = arr.length;
4242

43-
// Build max heap
4443
for (int i = (n ~/ 2) - 1; i >= 0; i--) {
4544
heapify(n, i);
4645
}
4746

48-
// Extract elements one by one
4947
for (int i = n - 1; i > 0; i--) {
5048
steps.add(SortingStep(index1: 0, index2: i, action: SortingStatus.swapping));
5149
arr.swap(0, i);
@@ -56,7 +54,6 @@ class HeapSortNotifier extends SortingNotifier {
5654
}
5755

5856
if (arr.isNotEmpty) heapSort();
59-
// Mark the first element sorted
6057
steps.add(SortingStep(index1: 0, index2: 0, action: SortingStatus.sorted));
6158

6259
return SortingResult(sortedValues: arr, steps: steps);

lib/features/sorting/merge/view_model/merge_sort_notifier.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,12 @@ class MergeSortNotifier extends SortingNotifier {
1212
int j = mid + 1;
1313

1414
while (i <= mid && j <= right) {
15-
// Compare current elements
1615
steps.add(SortingStep(index1: i, index2: j, action: SortingStatus.compared));
1716
steps.add(SortingStep(index1: i, index2: j, action: SortingStatus.unSorted));
1817

1918
if (arr[i] <= arr[j]) {
2019
i++;
2120
} else {
22-
// Bubble arr[j] left until it reaches position i
2321
int k = j;
2422
while (k > i) {
2523
steps.add(SortingStep(index1: k, index2: k - 1, action: SortingStatus.swapping));

0 commit comments

Comments
 (0)