Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Implement a method which takes three Stacks Stack allInput, evenOutput, OddOutpu

ID: 3600596 • Letter: I

Question

Implement a method which takes three Stacks Stack allInput, evenOutput, OddOutput object. The method pops each element from the stack allInput . If the element is even, it pushes the element in evenOutput stack, otherwise, in oddOutput stack. allInput stack should be empty after the operation.

• Implement another method which performs the same operation, but instead of three stacks, it takes three queues as parameters <<<<<<<<<<< Just this

IN JAVA PLZ

you could write it in psudocode or just code is fine.

Explanation / Answer



PSEUDOCODE

Algorithm StackOperation(Stack allInput , Stack evenOutput, Stack OddOutput)

START

while (!
allInput.isEmpty())
val =
allInput.pop()
if val%2 ==0
evenOutput.push(val)
else
OddOutput.push(val)

END



Algorithm QueueOperation(Queue allInput , Queue evenOutput, Queue  OddOutput)

START

while (!
allInput.isEmpty())
val =
allInput.dequeue()
if val%2 ==0
evenOutput.enqueue(val)
else
OddOutput.enqueue(val)

END


Thanks, let me know if there is any concern.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote