Académique Documents
Professionnel Documents
Culture Documents
By
Bubble sort
Quick sort
Heap sort
Radix sort
Selection sort
Merge sort
Insertion sort
Bubble sort algorithm
BUBBLE(DATA,N,PTR,K)
Here DATA is an array with N elements. This algorithm sorts the
elements of DATA in ascending order.
Step 1 :Repeat steps 2 and 3 for K=1 to N-1.
Step 2 :Set PTR:=1.[Initializes pass pointer PTR.]
Step 3:Repeat while (PTR<=N-K):[ Executes pass.]
(a) if( DATA[PTR]>DATA[PTR +1]),then:
Interchange DATA[PTR] and DATA[PTR+1].
(b) Set PTR:=PTR+1
[End of inner loop.]
[End of Step 1 outer loop.]
Step 4 : Exit.
How it works ?
Junaid_upesh@yahoo.com
Time over
Message from the presenter
This world is an echo, all comes back good or bad,
so give the world your best, best will return to you &
always have good opinion about others because this
is what you want from them.
Thank you for your cooperation
References:
Schaum ‘s outline of theory & problems of Data
structures.