Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Driven Web Sites

Authors: Mike Morrison, Joline Morrison

1st Edition

061901556X, 978-0619015565

More Books

Students also viewed these Databases questions

Question

d. How were you expected to contribute to family life?

Answered: 1 week ago

Question

Are robots going to displace all workers? Explain your answer.

Answered: 1 week ago