cancel
Showing results for 
Search instead for 
Did you mean: 

ST7 bubblesort

baggio10
Associate II
Posted on November 24, 2003 at 08:22

ST7 bubblesort

2 REPLIES 2
baggio10
Associate II
Posted on November 23, 2003 at 07:00

I'm at the beginning with st7 programmation and i'm looking for a program that implemented the bubblesort algorithm.

Thank you that help me

parveen
Associate II
Posted on November 24, 2003 at 08:22

for(i=0;i

{

for(j=i+1;j

{

if(data[i]>data[j])

{

temp=data[i];

data[i]=data[j];

data[j]=temp;

} //if loop

} //for j loop

}//for i loop

You can optimize the algorithm by exiting the loop if there is no swapping in a particular loop.

Hope this helps

Regards,

PraveenG