Question: Given an integer array nums as the following: Please finish four predefined methods for four tasks defined below: public static void reverseArray ( int [

Given an integer array nums as the following:
Please finish four predefined methods for four tasks defined below:
public static void reverseArray(int[] nums)
public static void rotateArray(int[] nums, int places)
public static void sortArray(int[] nums)
public static void largestElement(int[] nums)
Task 1: Reverse the array
In the reverseArray() method, you need to reverse the content of the array and print out the content.
Task 2: Rotate the array
In the rotateArray() method, you need to rotate the content of the array for a given number of places.
For example, if the number of places is 2, each element will shift to the right by 2 places, i.e., the index 0
element will occupy the index 2, the index 1 element will occupy the index 3. Note that if you reach the
boundary of the array, you should shift the content to the beginning of the array.
Task 3: Sort the array
In the sortArray() method, you need to sort the content of the array in an ascending order.
Task 4: Find the largest element in the array
In the largestElement() method, you need to find the largest element in the given array.
Expected results:
Note 1: All methods should use the same input array

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!