Question: NEED PSEUDOCODE FOR THIS CODING package stacks; import java.util.*; public class Stacks { /** * @param args the command line arguments */ public static void

NEED PSEUDOCODE FOR THIS CODING

package stacks;

import java.util.*;

public class Stacks {

/**

* @param args the command line arguments

*/

public static void main(String args[])

{

Scanner sc=new Scanner(System.in);

int n=sc.nextInt();

int array[]=new int[n];

for(int i=0;i

array[i]=sc.nextInt();

int A=0,B=n-1;

while(A<=B)

{

if(array[A]>array[B])

{

System.out.print("1 ");

B--;

}

else if(array[A]

{

System.out.print("2 ");

A++;

}

else{

System.out.print("0 ");

A++;

B--;

}

}

}

}

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!