To partition arrays and Deque
s of String
s
to experience the partition step of the Quicksort algorithm.
The completed assignment must be submitted as Homework 11 of CSCI 202 on Moodle by 11:00 PM Thursday, April 5.
Write two methods that implement that following headers:
public static Deque<String> partition(Deque<String>, String) ;
public static String[] partition(String[], String) ;
These methods receive an
array or Deque
of String
s and a pivot
String
.
They will return a new array or Deque
of String
s
which contains the same String
s as the input but where
the elements less than or equal to the pivot are stored at the beginning
of the new array or Deque
.
If a String
appears more than once in the input collection,
it should appear the same number of times in the output collection.
This actually makes the problem a lot easier.
This is not the same as partitioning the collection in place. Again, it is easier.