[solved]-Need Help Java Project Assignment Instrument Method Illustrate Insertion Sort Works Instru Q39008431
i need some help with a java project
For this assignment, you will instrument that method toillustrate how insertion sort works. Once you have instrumented themethod, create a driver program that initializes three differentarrays – one of Integers, one of Strings, and one of FacebookUserobjects – and call the insertion sort method on each one.
Next make an implementation of quick sort.
Create a generic version of the method that works on allComparable data types
Choose the pivot based on the median of the first three values.(If there are only one or two values in the array, then just usethe first one.)
Instrument the method to show the pivot and sub-arrays for eachpass.
here is my inserstion sort from a previous assignment.
public static > voidinsertionSort(ArrayList numbers) {
for(int i = 1; i <numbers.size(); i++) {
T key =numbers.get(i);
int j = i -1;
while(j >= 0&& numbers.get(j).compareTo(key)> 0) {
numbers.set(j+1, numbers.get(j));
j = j – 1;
}
numbers.set(j+1,key);
}
}
public static <T> void removeDuplicates(ArrayList<T> List) {
HashSet <T> seen = newHashSet<>();
Iterator <T> it =List.iterator();
while(it.hasNext()) {
T next =it.next();
if(seen.contains(next)) {
it.remove();
} else {
seen.add(next);
}
}
}
// have the main test the methods with different typesof data
public static void main(String[] args) {
// make a list of numbers andremove any repeats and then put in order
ArrayList<Integer> nums = newArrayList<>();
nums.addAll(Arrays.asList(10,20,30,23,3,8,3,10,38));
System.out.println(“Original NumberList : ” + Arrays.toString(nums.toArray()));
Utilities.<Integer>removeDuplicates(nums);
System.out.println(“After removingall duplicates ” + Arrays.toString(nums.toArray()));
Utilities.<Integer>insertionSort(nums);
System.out.println(“After sorting “+ Arrays.toString(nums.toArray()));
System.out.println();
// make a list of facebook users,remove any repeat people and then put in order.
ArrayList<String>facebookUsers = new ArrayList<>();
facebookUsers.add(“Dylan”);
facebookUsers.add(“Dylan”);
facebookUsers.add(“Hannah”);
facebookUsers.add(“Hannah”);
facebookUsers.add(“Larry”);
facebookUsers.add(“Bob”);
facebookUsers.add(“Larry”);
System.out.println(“Original Listof Users : ” + facebookUsers);
Utilities.<String>removeDuplicates(facebookUsers);
System.out.println(“After removingall duplicates ” + Arrays.toString(facebookUsers.toArray()));
Utilities.<String>insertionSort(facebookUsers);
System.out.println(“After sorting “+ Arrays.toString(facebookUsers.toArray()));
}
}
Expert Answer
Answer to i need some help with a java project For this assignment, you will instrument that method to illustrate how insertion so… . . .
OR

