Various Sorting techniques can be implemented to sort an Integer array .Some of them are
Bubble Sort:
Bubble Sorting is the Most Basic Sorting technique.The various steps in technique
1. Compare the two adjacent elements of the array
2. Check if one on the one on the left is large than one on the right, swap them.
3. Move to the right by one position.
The Code used for Implementing Bubble Sort is given Below
--------------------------------------------------------------
----------------------------------------------------------------
Other Sorting Techniques will discussed in the future posts.
- Bubble Sort
- Selection Sort
- Insertion Sort
- Quick Sort
- Merge Sort
- Heap Sort
Bubble Sort:
Bubble Sorting is the Most Basic Sorting technique.The various steps in technique
1. Compare the two adjacent elements of the array
2. Check if one on the one on the left is large than one on the right, swap them.
3. Move to the right by one position.
The Code used for Implementing Bubble Sort is given Below
--------------------------------------------------------------
void sort()
{
int x=l;
int y=0;
int a,b=0;
for (int rep=0;rep<l*4;rep++)
{
for(int i=0;i<x-1;i++)
{
a=ar[i];
b=ar[i+1];
if(a>b)
{
y=a;
a=b;
b=y;
ar[i]=a;
ar[i+1]=b;
}
}
}
}
----------------------------------------------------------------
Other Sorting Techniques will discussed in the future posts.
No comments:
Post a Comment