include<stdio.h>int main() { int t,i,j,temp=0; scanf("%d",&t); int a[t]; for(i=0;i<t;i++) {="" scanf("%d",&a[i]);="" }="" for(i="0;i<t;i++)" {="" for(j="0;j<t1;j++)" {="" if(a[j]="">a[j+1]) { temp=a[j]; a[j]=a[j+1]; a[j+1]=temp; } }
} asked 30 Jun '14, 23:06

You are using bubble sort. answered 30 Jun '14, 23:15

Adding to @pratku123 answer's, Here is a nice website : http://www.sortingalgorithms.com/ to fundamentally understand how different sorting algorithms works and it clears show no algorithm is best. In some cases insertion sort is more optimal than merge sort, and in some scenarios, though other sorts may take more time, but merge sort is avoided due to overhead and memory needs. answered 01 Jul '14, 00:35
