Saturday, July 30, 2011

Various Sorting Techniques used to sort the Elements of an Array:Bubble Sort-Selection Sort -Insertion Sort-Quick Sort-Merge Sort-Heap Sort

Various Sorting techniques can be implemented to sort an Integer array .Some of them are
  • 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++)


Other Sorting Techniques will discussed in the future posts.

No comments:

Post a Comment

Which is the Best Photo Watermarking Software

Photo Theft is becoming more and more common in the web with the outburst of social websites like Facebook,Google Plus and Image sharing se...