Answers

Question and Answer:

  Home  OS Data Structures

⟩ Explain simple algorithm for bubble sort?

void bubble(int x[],int n)

{

int hold,j,pass;

int switched=true;

for(pass=0;pass<n-1&&switched=true;pass++){

switched=false;

for(j=0;j<n-pass-1;j++)

if(x[j]>x[j+1]){

switched=true;

hold=x[j];

x[j]=x[j+1];

x[j+1]=hold;

}

}

}

 174 views

More Questions for you: