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 indegree of a graph?

0 Answers  


How does a treemap sort?

0 Answers  


Why hashmap is faster than hashset?

0 Answers  


What is an algorithm in coding?

0 Answers  


What is the difference between length () and size () of arraylist?

0 Answers  


Explain the principle of quicksort. What is its complexity?

0 Answers   HAL,


What is data type in data structure?

0 Answers  


What are linked lists good for?

0 Answers  


Differentiate between the singly linked list and doubly linked list.

0 Answers  


What do you mean by 2-3-4 tree?

0 Answers  


What is reduction to sorting method?

0 Answers  


applications of stacks and their uses?

1 Answers   Mind Tree, Samsung,


Categories