OS Data Structures Question:

Explain simple algorithm for bubble sort?

Tweet Share WhatsApp

Answer:

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;
}
}
}

Download OS Data Structures PDF Read All 14 OS Data Structures Questions
Previous QuestionNext Question
Tell me applications of linked lists and mostly used linked list?Explain applications of stacks and their uses?