April 2017
Beginner
504 pages
14h 11m
English
We will implement the quick sort with an extra class that is in the qsort package along with the partitioning class, which is as follows:
package packt.java9.by.example.ch03.qsort; // imports deleted from the print public class Qsort<E> { // constructor injected final fields deleted from the print public void qsort(SortableCollection<E> sortable, int start, int end) { if (start < end) { final E pivot = sortable.get(start); final Partitioner<E> partitioner = new Partitioner<>(comparator, swapper); int cutIndex = partitioner.partition(sortable, start, end, pivot); if (cutIndex == start) { cutIndex++; } qsort(sortable, start, cutIndex - 1); qsort(sortable, cutIndex, end); } } }
The method gets SortableCollection<E> ...
Read now
Unlock full access