MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / bubble_sort

Function bubble_sort

CPP/sorting/bubblesort.cpp:3–13  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1#include"bits/stdc++.h" //to include all the header files
2using namespace std;
3void bubble_sort(int arr[],int n)
4{
5 for (int i = 0; i < n; i++)
6 {
7 for (int j = 0; j < n-1-i;j++)
8 {
9 if(arr[j]>arr[j+1])
10 swap(arr[j],arr[j+1]);//using inbuilt swap function
11 }
12 }
13}
14int main(){
15 int arr[]={2,4,2,77,43,74,354,63,62,6222};
16 int n=sizeof(arr)/sizeof(int);

Callers 1

mainFunction · 0.85

Calls 1

swapFunction · 0.70

Tested by

no test coverage detected