Bubble Sort : Copied
Bubble Sort : Copied
#include<iostream>
using namespace std;
int main ()
{
int i, j,temp,pass=0;
int a[10] = {10,2,0,14,43,25,18,1,5,45};
cout <<"Input list ...\n";
for(i = 0; i<10; i++)
{
cout <<a[i]<<"\t";
}
cout<<endl;
for(i = 0; i<10; i++)
{
for(j = i+1; j<10; j++)
{
if(a[j] < a[i]) \
{
temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
pass++;
}
cout <<"Sorted Element List ...\n";
for(i = 0; i<10; i++)
{
cout <<a[i]<<"\t";
}
cout<<"\nNumber of passes taken to sort the list:"<<pass<<endl;
return 0;
}
Insertion Sort
#include"iostream"
#include"conio.h"
using namespace::std;
int main(void)
{
int n;
cin.ignore(); cin.get();
}
void insert_sort(int *arr, int s)
{
Merge Sort
#include"iostream"
#include"conio.h"
using namespace::std;
for(j=0;j<n2;j++)
{
R[j]=Arr[md+j];
}
L[n1]=9999;
R[n2]=9999;
i=0;
j=0;