answersLogoWhite

0

Bubble sorting in c plus plus?

User Avatar

Anonymous

13y ago
Updated: 8/19/2019

bubble_sort (int N, int *A) {

int i; swap = 1;

while (swap) {

swap = 0;

for (i=0; i<N-1; ++i) {

if (A[i] > A[i+1]) {

swap = 1;

A[i] ^= A[i+1];

A[i+1] ^= A[i];

A[i] ^= A[i+1];

}

}

}

}

User Avatar

Wiki User

13y ago

What else can I help you with?

Related Questions

Is bubble sort a stable sorting algorithm?

Yes, bubble sort is a stable sorting algorithm.


Different types of sorting techniques in c language?

types of sorting in c language are: insertion sort selection sort bubble sort merge sort two way merge sort heap sort quick sort


What are the different types of sorting?

insertion,bubble,quick, quick3, merge, shell,heap, selection sorting


Using only one program implement bubble sorting insertion sorting quick sorting and selection sorting?

Its simple!dirve a menu based prog by using switch case &amp; then apply every sorting function to it.


What are some sorting rules for math?

Binary sort and bubble sort are two.


Which is best sorting in c plus plus?

Every sorting algorithm has pros and cons; there is no "best" algorithm for every situation. Quick sort is generally considered to be the "best", but even a bubble sort will outperform it when there are relatively few items to consider, and optimisation is required to cater for equal items to ensure they remain in a stable sequence. The following article compares the efficiency of each of the popular algorithms, but note that the big O times reflect the standard, unoptimised algorithms.


What are the types of sort algorithms?

insertion,bubble,quick, quick3, merge, shell,heap, selection sorting


What are the different types of algorithm?

insertion,bubble,quick, quick3, merge, shell,heap, selection sorting


Which sorting algorithm is more efficient for small datasets: bubble sort or selection sort?

Selection sort is more efficient for small datasets compared to bubble sort.


Sorting numbers using user-defined functions in C programming?

Assume your numbers are into an array. Then write any user-defined function implementing any kind of sorting. I am giving example of bubble sort.void bubble(int a[],int n){int i,j,t;for(i=n-2;i>=0;i--){for(j=0;ja[j+1]){t=a[j];a[j]=a[j+1];a[j+1]=t;}}}}


Which is the easiest sorting method?

There are generally eight sorting algorithms that are studied in school by computer science students. They are as follows: insertion, bubble, quick, quick3, merge, shell, heap, and selection sorting. There are different types of sorting algorithms. One would be considered good if it is accurate and efficient. Different types of sorting includes; sequential, ascending, and descending.


What is mean by sorting in c?

arranging items in some ordered sequence,