-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbubble_sort.js
More file actions
26 lines (21 loc) · 885 Bytes
/
bubble_sort.js
File metadata and controls
26 lines (21 loc) · 885 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
25
26
function Bubble() {
c_delay = 0;
for (var i = 0; i < array_size - 1; i++) {
for (var j = 0; j < array_size - i - 1; j++) {
div_update(divs[j], div_sizes[j], "yellow"); //Color update
if (div_sizes[j] > div_sizes[j + 1]) {
div_update(divs[j], div_sizes[j], "red"); //Color update
div_update(divs[j + 1], div_sizes[j + 1], "red"); //Color update
var temp = div_sizes[j];
div_sizes[j] = div_sizes[j + 1];
div_sizes[j + 1] = temp;
div_update(divs[j], div_sizes[j], "red"); //Height update
div_update(divs[j + 1], div_sizes[j + 1], "red"); //Height update
}
div_update(divs[j], div_sizes[j], "blue"); //Color updat
}
div_update(divs[j], div_sizes[j], "green"); //Color update
}
div_update(divs[0], div_sizes[0], "green"); //Color update
enable_buttons();
}