0 added
0 removed
Original
2026-01-01
Modified
2026-03-09
1
<p>Fix the sorting function so that the states of the array during sorting match the sample.</p>
1
<p>Fix the sorting function so that the states of the array during sorting match the sample.</p>
2
<p>To view the sample or test your program, click the button Boss, here’s your program!</p>
2
<p>To view the sample or test your program, click the button Boss, here’s your program!</p>
3
<p><strong>Solution</strong></p>
3
<p><strong>Solution</strong></p>
4
<p>The solution to the challenge will be available in a few minutes. Use it if you encounter difficulties. In the meantime, try to complete the challenge on your own.</p>
4
<p>The solution to the challenge will be available in a few minutes. Use it if you encounter difficulties. In the meantime, try to complete the challenge on your own.</p>
5
let arr = [7, 1, 5, 2]; draw(arr); bubbleSort(arr); function bubbleSort(arr) { let len = arr.length - 1; for (let i = 0; i < len; i++) { for (let n = 0; n < len - i; n++) { if (arr[n] > arr[n + 1]) { let temp = arr[n]; arr[n] = arr[n + 1]; arr[n + 1] = temp; draw(arr, n, n + 1); } } } }
5
let arr = [7, 1, 5, 2]; draw(arr); bubbleSort(arr); function bubbleSort(arr) { let len = arr.length - 1; for (let i = 0; i < len; i++) { for (let n = 0; n < len - i; n++) { if (arr[n] > arr[n + 1]) { let temp = arr[n]; arr[n] = arr[n + 1]; arr[n + 1] = temp; draw(arr, n, n + 1); } } } }