forked from algorithm-visualizer/algorithm-visualizer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode.js
More file actions
24 lines (23 loc) · 637 Bytes
/
code.js
File metadata and controls
24 lines (23 loc) · 637 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
//set counts values
for (let i = 0; i < A.length; i++) {
tracer._select(0, i)._wait();
counts[A[i]]++;
tracer._notify(1, A[i], D[1][A[i]])._wait();
tracer._deselect(0, i);
tracer._denotify(1, A[i], D[1][A[i]])._wait();
}
//sort
var i = 0;
for (var j = 0; j <= maxValue; j++) {
while (counts[j] > 0) {
tracer._select(1, j)._wait();
sortedA[i] = j;
counts[j]--;
tracer._notify(1, j, D[1][j]);
tracer._notify(2, i, D[2][i])._wait();
tracer._deselect(1, j);
tracer._denotify(1, j, D[1][j]);
tracer._denotify(2, i, D[2][i])._wait();
i++;
}
}