I have been looking at different videos and read different articles on the quicksort algorithm.
I understand how it works and if I didn't there is plenty of material online for me to look into. The problem I am having here is that some of the articles I found state the following (from wikipedia) :
Reorder the array so that all elements with values less than the pivot come before the pivot, while all elements with values greater than the pivot come after it (equal values can go either way). After this partitioning, the pivot is in its final position. This is called the partition operation.
some other sources, (hackerrank video):
We swap elements around such that all elements smaller than the pivot come before elements that are bigger than the pivot
There is a substantial difference in these two algorithms. The first one splits the array using the pivot, and puts everything that is smaller on one side, and everything that is larger on the other.
The second one would not be concerned with the pivot itself, but it would make sure that all elements smaller than the pivot come before the ones that are bigger. Where the pivot ends up is not even mentioned.
So if this was the array to sort [3, 15, 4, 8, 12] and the pivot was 8
solution 1: [3, 4, 8, 15, 12]
solution 2: [3, 8, 4, 15, 12]
I found so many conflicting opinions that I wonder if this matters or not, but I would like to know if there is a right way of implementing it, or it can vary.