Skip to main content

Posts

Showing posts from November, 2019

Quick Sort Program - C Source Code

#include<stdio.h> int partition(int a[25],int first,int last) { int i, j, pivot, temp; if(first<last) {   pivot=a[first];   i=first;   j=last;   while(i<j)   {      while(a[i]<=pivot&&i<last)     i++;      while(a[j]>pivot)     j--;      if(i<j)      {     temp=a[i];     a[i]=a[j];     a[j]=temp;      }   }   temp=a[first];   a[first]=a[j];   a[j]=temp; }   return(j); } void quicksort(int a[25],int first,int last) { int j; if(first<last) { j=partition(a,first,last); quicksort(a,first,j-1); quicksort(a,j+1,last); } } int main(){ int i, count, a[25]; clrscr(); printf("Enter some elements (Max. - 25): "); scanf("%d",&count); printf("Enter %d elements: ", count); for(i=0;i<count;i...