Question: Develop body of the Java method void move(int[] arr) { } that takes an array of integers as an argument, and moves all negativevalues of
Develop body of the Java method
void move(int[] arr) { }
that takes an array of integers as an argument, and moves all negativevalues of the array to the end of the arraypreservingthe order of the elementswithoutusing temporary arrays.
Examples:
if arr ={6, -4, 7, -2, 7, 5, 8, 2}, then the result would be { 6, 7, 7, 5, 8, 2, -4, -2}.
Note that the order of the numbers have not been changed. even-4 appears before -2.
if arr ={-4, -7, 6, -3, -4, -7}, then the result would be {6, -4, -7, -3, -4, -7}.
Notes:
1. You shouldnotuse temporary arrays, otherwise your solution will not be marked.
3. Use top-down design methodology, and split your method into sub methods. Note that each method should do one job.
4. You will be marked based on the correctness and quality of your code.
public static void move(int[] arr) {
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
