Skip to content
Advertisement

Tag: stack

How to deploy stack with docker-java client?

How to deploy stack with docker-java client? ex) docker stack deploy –compose-file docker-compose.yml stackdemo Is there any function to run this command in java client? Answer If you want to execute multiple commands I suggest you to write a shell script file and execute it from the java code. Another option if you want to only run 1 command you

arrayImpOfStack.java how to reverse number in output?

I need to write arrayImpOfStack.java then write a main method to read a sequence of numbers and using the stack operation print them in reverse order How to reverse number in output ? I have 2 class class 1 and i have class main Answer You can do it recursively: In your case: Full Example:

Not displaying elements from stack

So I have written this JAVA-program for stack and the problem is I cant display the elements using the display() method which I used in the code. here is my Stack class. public class Stack { //members …

Is this a stack?

Is this code a stack? How I can make it better? This is my first one. Can i do this using ArrayList? I didn’t added the isEmpty() method. Answer Yes, it is. But you can add checking for overflow, underflow. And this will be better if you’ll try using collections.

Parenthesis/Brackets Matching using Stack algorithm

For example if the parenthesis/brackets is matching in the following: and so on but if the parenthesis/brackets is not matching it should return false, eg: and so on. Can you please check this code? Thanks in advance. Answer Your code has some confusion in its handling of the ‘{‘ and ‘}’ characters. It should be entirely parallel to how you

How to remove certain items from a Stack [closed]

It’s difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 9 years ago. I have a homework problem in which I need to remove all the

Knight’s tour depth-first search infinite loop

I’m trying to solve the knight’s tour problem using a depth-first search algorithm. The algorithm seems te be looping whenever it has two choices that both result in a dead end. I understand that this is caused because the algorithm resets the ‘wasVisited’ boolean to false again whenever a dead end is found but i simply don’t know how to

Advertisement