This function is called with A and 7 as parameters where the array A initially contains the
elements 34,14,65 be the value of the elements in A after 3 iterations of the outer loop?
Function bubbleSort(A, n)
{
For i = @ to n-2 step 1
for j = o to n-1-2 step 1
if (A (j) > A(j+1))
swap(A(J), A(+1))
}
a. 14 12 22 5 34 65 71
b. 14 34 22 12 65 5 71
c. 14 22 12 34 5 65 71
Answers
Answered by
0
Answer:14,12,22,5,34,65,71
Explanation:
Answered by
0
Answer:
(a) 14 12 22 5 34 65 71
Explanation:
The bubble sort algorithm works in such a way that, it tries to check always the adjacent element. If the adjacent element is less than the current element, then it swap. Otherwise it keeps the number in the same position. The number of iteration always depends on how the elements are organized. If there are only fewer number where the arrangements are needed then the bubble sort gives a quicker result.
Similar questions