Let's check if the following array is sorted in ascending order.
{
"array": [10,20,30,40,50],
"showIndices": true
}
Compare index 0 and 1
Compare 10
and 20
.
10 ≤ 20 → OK
{
"array": [10,20,30,40,50],
"showIndices": true,
"highlightIndices": [0,1],
"labels": {"0":"i","1":"i+1"}
}
Compare index 1 and 2
Compare 20
and 30
.
20 ≤ 30 → OK
{
"array": [10,20,30,40,50],
"showIndices": true,
"highlightIndices": [1,2],
"labels": {"1":"i","2":"i+1"}
}
Compare index 2 and 3
Compare 30
and 40
.
30 ≤ 40 → OK
{
"array": [10,20,30,40,50],
"showIndices": true,
"highlightIndices": [2,3],
"labels": {"2":"i","3":"i+1"}
}
Compare index 3 and 4
Compare 40
and 50
.
40 ≤ 50 → OK
{
"array": [10,20,30,40,50],
"showIndices": true,
"highlightIndices": [3,4],
"labels": {"3":"i","4":"i+1"}
}
Final Result:
Array is sorted.