Connecting Tech Pros Worldwide Forums | Help | Site Map

How do I use quicksort in C?

Newbie
 
Join Date: Dec 2008
Posts: 17
#1: Oct 22 '09
Is there a ready function in stdlib.h?

Thanx in advance!
best answer - posted by donbock
Look up the documentation of stdlib.h function qsort().

Don't let the function name fool you. This function need not use the "Quicksort" algorithm. Notice that if two or more elements compare equal, qsort can leave these elements in any relative order.

If you must absolutely use the "Quicksort" algorithm then you need to write your own function.

Expert
 
Join Date: Mar 2008
Location: Naperville, Illinois U.S.
Posts: 831
#2: Oct 22 '09

re: How do I use quicksort in C?


Look up the documentation of stdlib.h function qsort().

Don't let the function name fool you. This function need not use the "Quicksort" algorithm. Notice that if two or more elements compare equal, qsort can leave these elements in any relative order.

If you must absolutely use the "Quicksort" algorithm then you need to write your own function.
Newbie
 
Join Date: Dec 2008
Posts: 17
#3: Oct 22 '09

re: How do I use quicksort in C?


Quote:

Originally Posted by donbock View Post

Look up the documentation of stdlib.h function qsort().
If you must absolutely use the "Quicksort" algorithm then you need to write your own function.

Thanx for the help! I saw the documentation and it was quite difficult to understand, especially the 4th argument.. Anyway I will write it on my own :( . That's what I thought in the first place anyway.. I was just curious if there were one ready algorithm. :D
Reply