Description
Algorithm of the bubble sort
Presentation Transcript
Algorithm : Algorithm Let A[n] be an array required to be sorted in descending order :
Step 1 : Start
Step 2 : set i to 0
Step 3 : while(iA[i] ) then do step10 thru step12 else do step13
{
Step10 : set temp = A[i] [value of a[j] is stored in a temporary
variable ‘temp’]
Step11 : A[i] = A[j]
Step12 : A[j] = temp
} [ end of ‘if ’ condition ]
Step13 : add 1 to j [ end of the inner loop ‘j’ ]
}
Step14 : add 1 to i [ end of the outer loop ‘i’ ]
}
Step15 : Print the sorted array
Step16 : end
Your Facebook Friends on WizIQ