Data Structure

Bubble Sort

Learn data-structure by example of bubble sort algorithm

4/19/2021
0 views
bubble-sort-algorithm.cC
/* Bubble Sort */
void bubsort(E A[], int n) {
	for (int i=0; i<n-1; i++)

		/* Bubble up i'th record */
		for (int j=n-1; j>i; j--)
			if (Comp::prior(A[j], A[j-1]))
				swap(A, j, j-1);
}
bubble sortdata structuredata structure algorithmbubble sort algorithm

Loading comments...

Related Examples