please HELP! im implementing quicksort algorithm with the last element in the array as my pivot. but my output comes out to be in the same order as i put them in the array(not sorted at all!!). idk what im doing wrong. please help!
How did you implement your swap? What language is this in? Have you done any break points or prints to see what is happening at different parts of the process?
c++. the swap function is written there in the file.
OK, so is the swap function actually being called and if so is it actually swapping things?
I actually never tried breakpoints. I don't know how it works.
Those depends on the compiler. A few print statements or cout can be just as useful. For example, with a quicksort you are going to have recursive calls. OK. So have it output something every time it is recursively called.
ok. i fixed the swap part, along with the partition. now these two functions work perfectly. Te partition is now the problem right now.
and i just realized i never posted the file before in the first place. my brain...
i mean to say the quicksort* function is the problem.
Take a look at this version: http://www.algolist.net/Algorithms/Sorting/Quicksort/Full
thx but i managed to fix the problem. now i just need to be able to change it up so it returns the index array, instead of the sorted elements.
Join our real-time social learning platform and learn together with your friends!