![]() |
| | #1 |
| Registered User Join Date: Sep 2008
Posts: 7
| |
| internet_bug is offline | |
| | #2 |
| Registered User Join Date: Oct 2006 Location: Canada
Posts: 848
| 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. |
| nadroj is offline | |
| | #3 |
| Registered User Join Date: Apr 2006 Location: United States
Posts: 3,202
| 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;
}
__________________ Os iusti meditabitur sapientiam Et lingua eius loquetur indicium "There is nothing either good or bad, but thinking makes it so." (Shakespeare, Hamlet, Act II scene ii) http://www.myspace.com/whiteflags99 |
| whiteflags is offline | |
| | #4 |
| and the hat of vanishing Join Date: Aug 2001 Location: The edge of the known universe
Posts: 21,214
|
__________________ If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut. Up to 8Mb PlusNet broadband from only £5.99 a month! |
| Salem is offline | |
| | #5 | |||
| Registered User Join Date: Sep 2008
Posts: 7
| Quote:
Quote:
Quote: excelelnt site M8, this will be quite useful to me | |||
| internet_bug is offline | |
![]() |
| Tags |
| quick, sort |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| another sort useless program | mrsirpoopsalot | C Programming | 21 | 09-18-2006 02:35 AM |
| How to fix misaligned assignment statements in the source code? | biggyK | C++ Programming | 28 | 07-16-2006 11:35 PM |
| Quick sort | Saiyanman | C Programming | 4 | 07-30-2002 10:16 PM |
| bubble sort in assembly language!!!!!! | lorenzohhh | C++ Programming | 1 | 04-15-2002 08:30 PM |
| Hey guys I ned some quick help here with a little program, please. | Desperado | C++ Programming | 34 | 11-26-2001 01:17 PM |