I know what is Bubble sort but can anyone please tell me what exaclty is Quick Sort and i also wanted a program for it, thankz in advance
I know what is Bubble sort but can anyone please tell me what exaclty is Quick Sort and i also wanted a program for it, thankz in advance
no one is going to "give you a program for it". anyways, theres no "QuickSort_v1.exe". its an algorithm, not a program. theres a website called wikipedia (sorry i forget the link, google it may be able to find it). search quicksort there and you will get all you need to know.
also note that there is a one-to-one correspondence of the amount of work you spend on your post and the quality of responses.
Since you can find out how quick sort works using the internet, I'll leave finding the details to you. But quick sort usually works by selecting a pivot value, then partitioning the array around the value. (Partitions are guaranteed to place at least one element in its sorted position.) Do this recursively, and after every element has been selected as a pivot, then the sequence is sorted.
Now, C implemented the quick sort algorithm for you:
Code:#include <stdlib.h> int compare (const void * a, const void * b) { const int * c = a; const int * d = b; if (*c < *d) return -1; else if (*c > *d) return 1; else return 0; } int main () { int sortme[] = {6, 4, 8, 5, 1, 2, 3, 7, 9,}; qsort(sortme, 9, sizeof(int), compare); return 0; }
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
thankz for the site, it's www.wikipedia.net, great site it provided a lot of info
millions of thankz mate
excelelnt site M8, this will be quite useful to me