Question: In some programming languages, arrays or lists have a built-in method called reverse that reverses all elements in a list in place. Given an integer


In some programming languages, arrays or lists have a built-in method called reverse that reverses all elements in a list in place. Given an integer array and two index values, your task is to write a program to in place reverse all elements in the array slice in Java. Program Description Write the main program that takes an array t with its size n and two indexes, start and stop, as its user input arguments, and reverses all elements in the array slice t [start:stop] in place and prints the final state of your array. The program does not return anything useful to stress the fact that it modifies the array. If the array slice is empty, array t is left unmodified. Plese NOTE that array indexes may be zero, positive, or negative, or may even indicate a slice that is empty. Your solution must handle all such situations. The order of the remaining elements in the array must be preserved. DO NOT USE ANY JAVA BUILT-IN ARRAY FUNCTIONS TO REVERSE. Constraints - None Explanation Reverses all the array slice elements between indexes [3,7] and prints the final state of array. - Sample Case 1 Sample Input For Custom Testing 10 0123456789 24 Sample Output [0,1,5,4,3,2,6,7,8,9] Explanation Reverses all the array slice elements between indexes [2,4] and prints the final state of array
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
