#include <stdbool.h>
      #include <stdio.h>
      #include <stdlib.h>
      
      void bubbleSort(int *A, int n) {
      	bool isSwapped;
      	int i, temp;
      	do {
      		isSwapped = false;
      		for (i = 0; i < n; i++) {
      			if (A[i - 1] > A[i]) {
      				temp = A[i - 1];
      				A[i - 1] = A[i];
      				A[i] = temp;
      				isSwapped = true;
      			}
      		}
      	} while (isSwapped);
      }
      
      C language logo

      Bubble Sort

      Codiga's C Recipes

      Bubble Sort implementation

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.