Difference between Bubble and selection sorting
what is the difference between bubble sorting and selection sorting whereas the code same of both sorting but different algorithm why it is so....???
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
#include <iostream>
#include <conio.h>
using namespace std;
int main ()
{
const int ARRAY_SIZE = 10;
int num[ARRAY_SIZE]={0};
int swap;
for (int i=0 ; i<ARRAY_SIZE ; i++)
{
cout << "enter the value # "<< i+1<<" ";
cin >> num[i];
}
for (int i=0 ; i< ARRAY_SIZE ; i++)
{
for(int j=0 ; j<ARRAY_SIZE ; j++)
{
if (num[j]>num[j+1])
{
swap = num[j];
num[j] = num[j+1];
num[j+1] = swap;
}
}
}
cout << "sorted arrays"<<endl;
for (int i=0 ; i<ARRAY_SIZE ; i++)
{
cout <<num[i];
cout << endl;
}
}
|
Difference between Bubble and selection sorting |
You can just type that in google.
thank you sooo much ..... :/
Topic archived. No new replies allowed.