simple algorithm for bubble sort?

Answer Posted / siri

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

Is This Answer Correct ?    4 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is stack explain with diagram?

594


What are arrays used for?

617


What are the classification of data structures?

574


What is dynamic array how is it created?

555


What is the non linear data structure?

553






Write the recursive c function to count the number of nodes present in a binary tree.

554


Why concurrenthashmap is fail safe?

598


What is the best time complexity of bubble sort?

602


Define a complete binary tree?

611


What exactly is data?

592


Are the expressions arr and &arr same for an array of integers?

658


Write the importance of hashing?

684


What is an recursive algorithm?

614


Differentiate between comparable and comparator.

721


How do you sort large data?

657