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 reverseArrayint nums
public static void rotateArrayint nums, int places
public static void sortArrayint nums
public static void largestElementint nums
Task : Reverse the array
In the reverseArray method, you need to reverse the content of the array and print out the content.
Task : 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 each element will shift to the right by places, ie the index
element will occupy the index the index element will occupy the index Note that if you reach the
boundary of the array, you should shift the content to the beginning of the array.
Task : Sort the array
In the sortArray method, you need to sort the content of the array in an ascending order.
Task : 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 : 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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
