Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

Why do we need to recycle?

835


Is linked list faster than array?

834


How does a binary search work?

842


Explain about set and their types in a collection?

843


What is bubble sort technique?

854


How will you free the memory that is allocated at run time?

957


What is a Stack? Explain with example?

944


Which sorting algorithm uses minimum number of swaps?

836


Is an arraylist a vector?

948


What do you mean by general trees?

997


When is a binary search best applied?

866


What is sorting with example?

881


Devise a program to sort an array using bubble sort.

1018


Can I provide array size dynamically?

922


Explain what are the major data structures used in the hierarchical data model?

981