2. WHAT IS SORTING? Sorting refers to ordering data in an
increasing or decreasing fashion according to some linear
relationship among the data items. Sorting can be done on names,
numbers and records.
4. WHAT IS BUBBLE SORT? This technique compares last element
with the preceding element. If the last element is less than that
of preceding element swapping takes place. Then the preceding
element is compared with that previous element. This process
continuous until the II and I elements are compared with each
other. This is known as pass 1. This way the number of passes would
be equal to size of array 1.
5. WHO BUBBLE SORT WORKS?
6. ALGORITHM OF BUBBLE SORT for i = 1:n, swapped = false for j
= n:i+1, if a[j] < a[j-1], swap a[j,j-1] swapped = true end
invariant: a[1..i] in final position break if not swapped end Main
LoopInner Loop