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

Define shortest path?

0 Answers  


Tell me what is quick sort?

0 Answers  


What is frozenset?

0 Answers  


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

0 Answers  


Why might quick sort might be better than merge sort?

0 Answers  






Define a full binary tree ?

0 Answers  


Does hashmap allow duplicate keys?

0 Answers  


What is concurrentlinkeddeque?

0 Answers  


What is the difference between Array and Arraylist?

0 Answers  


Tell me do array subscripts always start with zero?

0 Answers  


What does the term sorting refer to?

0 Answers  


Complete structure of hashmap, very detail description, along with the basic coding of the hashmap internal implementation.

0 Answers   Expedia,


Categories