Computing Course AlgorithmBubble Sort Implemented in : Turbo Pascal 6.0 (ish) DescriptionBubble sort (Procedure only) Explanation Warning (Plagiarism) procedure bubble( list : array_type; n : integer) flag : boolean; count, temp : integer begin repeat begin flag := false; for count in 1 to n loop if list[count+1] > list[count] then ....temp := list[count]; ....list[count] := list[count + 1]; ....list[count + 1] := temp; ....flag := true; end if; end loop; until flag=false; end bubble; Explanation : Bubble Sort list is the array we are sorting, n is the number of elements in the array. First you set the "flag" to false to say there have been ne swaps. loop around between 1 and the number of elements in the array. for each loop test that position against the next position to see if a swap is needed, if so then swap the items over using the temporary variable temp. set flag to true to say there has been a swap this pass, Once the array has been checked once, ie count has gone between 1 and n, if there are no swaps done everything is in order and we drop out of the array, if flag is true then we "repeat" the whole process again, until no swaps are made... This process can be made slightly quicker, on the first pass the highest number will always "float" to the top end of the array, therefore this element needn't be checked next pass around, simmerly on the second pass, two numbers at the top of the array will be in order... slowly decreasing the number of items needing to be checked. Another variable "bottom" can be included here to do this it's incremented every pass, and on the next pass you loop "1 to n-bottom" times. If you need any furthur help with this don't hesitate in contacting me... I'll try to help.