simple algorithm for bubble sort?



simple algorithm for bubble sort?..

Answer / 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

More Data Structures Interview Questions

How to do the intersection of two sorted arrays?

0 Answers  


What is difference between for loop and foreach?

0 Answers  


Can hashmap store null values?

0 Answers  


Differentiate stack from array?

0 Answers  


How do you sort pseudocode?

0 Answers  






What is the complexity of sorting algorithm?

0 Answers  


Which is faster quick sort or merge sort?

0 Answers  


What are the main differences between the linked list and linear array?

0 Answers  


What are different dynamic memory allocation technique in c.

0 Answers  


What is the maximum size of array?

0 Answers  


example of linear and non-linear data structures?

9 Answers   Aricent, Infosys,


Are dictionaries mutable?

0 Answers  


Categories