Question: In Java: Write two static genetic methods maxElement() and minElement(). The methods take an array of objects of an arbitrary type and find the largest
In Java:
- Write two static genetic methods maxElement() and minElement(). The methods take an array of objects of an arbitrary type and find the largest and the smallest objects correspondingly. The type of objects must be limited to those that implement Comparable interface.
- Modify quicksort() implementation in such a way that it becomes a generic method and can work with objects that implement Comparable interface. Add it as a static method to GenericMethods class. Make this quicksort() have a boolean parameter that determines whether the array will be sorted in ascending or descending order. See examples below:
int[] array = {3, 5, 6, 1, 2, 4}; GenericMethods.quicksort(array, true); => {1, 2, 3, 4, 5, 6} GenericMethods.quicksort(array, false); => {6, 5, 4, 3, 2, 1} Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
