Recursive sorting

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, ...

Get Java Projects - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.