Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfe3adcf

Browse files
authored
Fix counts array visualization in Counting Sort (#28)
* Fix counts array visualization in Counting SortFinal step did not correctly visualize decrementing the value in the counts array.It was decrementing the value but not updating the visualization.* Add countsTracer.depatchMy previously committed code left the boxes in the counts array colored red, so I realized I had forgotten to add a depatch after the patch that I added at line 66
1 parent7138698 commitfe3adcf

File tree

1 file changed

+3
-1
lines changed
  • Divide and Conquer/Counting Sort

1 file changed

+3
-1
lines changed

‎Divide and Conquer/Counting Sort/code.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,17 @@ const array = Randomize.Array1D({ N, value: () => Randomize.Integer({ min: 0, ma
5858
constnumber=array[i];
5959
constcount=counts[number];
6060
sortedArray[count-1]=number;
61+
counts[number]--;
6162
// visualize {
6263
arrayTracer.select(i);
6364
countsTracer.select(number);
6465
sortedArrayTracer.patch(count-1,sortedArray[count-1]);
66+
countsTracer.patch(number,counts[number]);
6567
Tracer.delay();
6668
sortedArrayTracer.depatch(count-1);
69+
countsTracer.depatch(number);
6770
countsTracer.deselect(number);
6871
arrayTracer.deselect(i);
6972
// }
70-
counts[number]--;
7173
}
7274
})();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp