Let array A: 90, 75, 42, 82, 10. Apply bubble sort algorithm to sort the array.
Solve:
Pass 1 :
90 75 42 82 10
75 90 42 85 10
75 42 90 82 10
75 42 82 90 10
75 42 82 10 90
Pass 2:
75 42 82 10 90
42 75 82 10 90
42 75 82 10 90
42 75 10 82 90
Pass 3:
42 75 10 82 90
42 75 10 82 90
42 10 75 82 90
Pass 4:
40 10 75 82 90
10 42 75 82 90
Pass 1 :
90 75 42 82 10
75 90 42 85 10
75 42 90 82 10
75 42 82 90 10
75 42 82 10 90
Pass 2:
75 42 82 10 90
42 75 82 10 90
42 75 82 10 90
42 75 10 82 90
Pass 3:
42 75 10 82 90
42 75 10 82 90
42 10 75 82 90
Pass 4:
40 10 75 82 90
10 42 75 82 90
No comments
Post a Comment