August 2018
Intermediate to advanced
524 pages
14h 45m
English
We will implement the quicksort with an extra class that is in the qsort package along with the partitioning class, which is as follows:
package packt.java189fundamentals.ch03.qsort; // ... imports are deleted from print ... public class Qsort<E> { final private Comparator<E> comparator; final private Swapper swapper; // ... constructor setting fields deleted from print ... public void qsort(Sortable<E> sortable, int start, int end) { if (start < end) { final var pivot = sortable.get(start); final var partitioner = new Partitioner<E>(comparator, swapper); var cutIndex = partitioner.partition(sortable, start, end, pivot); if (cutIndex == start) { cutIndex++; } qsort(sortable, start, cutIndex - 1); qsort(sortable, cutIndex, ...