Question: ***********JAVA************** HW3_P3 - Push zero to front Given an array A, push all the zeros of the array to the front. The order of all

***********JAVA**************

HW3_P3 - Push zero to front

Given an array A, push all the zeros of the array to the front. The order of all other elements should remain same.

Write a function: void pushZero(int array[])

that accepts an integer array A and size of the array, N. The function should convert the original array as per above requirement.

Input 10 2 0 3 4 0 4 0 10 9 0

where,

-First line represents size of an array N.

-Second line represents array elements. There must be single space between each element.

There should be one space after the last element.

Output 0 0 0 0 2 3 4 4 10 9

There must be single space between each element of output array.

There should be one space after the last element.

N is an integer within the range [1 to 1,000,000].

*******Use the following class driver with no modifications to it!********

import java.util.*; import java.lang.*; import java.io.*;

class DriverMain{

public static void main(String args[]){

HW3_P3 hw3P3 = new HW3_P3();

int[] array = hw3P3.getArray();

hw3P3.pushZero(array);

//Print the result array

for(int i=0;i

System.out.print(array[i]+" ");

}

}

}

******************************************************************************

---And use the following class HW3_P3 that was refered to in main----

class HW3_P3{ public int[] getArray(){ Scanner scanner = new Scanner(System.in); //write your code to get the array and return it } public void pushZero(int array[]){ // write your code } }

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!