answersLogoWhite

0

Simple c program for quicksort

User Avatar

Anonymous

13y ago
Updated: 8/17/2019

#include<stdio.h>

void print(int a[])

{

int i;

for( i=0;i<=8;i++)

{

printf("%d ",a[i]);

}

}

int Qsort(int data[], int left, int right)

{

int mid,tmp,i,j;

i = left;

j = right;

mid = data[(left+right)/2];

do

{

while (data[i] < mid)

i++;

while (mid < data[j])

j--;

if (i <= j)

{

tmp = data[i];

data[i] = data[j];

data[j] = tmp;

i++;

j--;

}

}

while (i <= j);

{

if (left < j)

Qsort(data,left,j);

if (i < right)

Qsort(data,i,right);

}

}

main()

{

int array[]={12,99,4,99,12,12,13,10,13};

printf("Before sort:\n\n");

print(array);

Qsort(array,0,8);

printf("\n\nAfter sort:\n\n");

print(array);

printf("");

}

User Avatar

Wiki User

13y ago

What else can I help you with?

Related Questions

Simple c language program?

Well, this is a very open question, please be specific, I will try try to answer this as well, a simple c language program can be any thing from printing your name on the screen to printing some patterns using symbols, or making a small game, or a simple calculator program. you can a clearer picture of what can be a simple c language program here:


What is algorithms in c or c plus plus?

it is a step by step program written in simple English for our understanding


Is quicksort a stable sorting algorithm?

No, quicksort is not a stable sorting algorithm.


C program algorithm for simple interest using while loop?

Not used


Why you use count in simple interest program in c?

You mean 'count' as variable-name? It is optional.


How do you write a C program to find the Simple Interest?

Reference:cprogramming-bd.com/c_page1.aspx#simpleinterest


Write a c program for false position method?

Write a simple program in finding roots x^3-6x^2+11x-6.1=0


Which is faster among quicksortmergesort?

quicksort


What is quicksort?

Quicksort is a popular algorithm to sort items in software, aiming at completion in the smallest number of steps (shortest time) possible.


You want to write a simple without using pointer or array c program which will print greatest number when you give 20 number?

i want to write a simple without using pointer or array c program which will print greatest number when i give 20 number .........How far have you gotten so far?


Show the simple c plus plus program?

int main (void) { puts ("Hello, world"); return 0; }


Features of c program?

the features of a C program