Question: I need a method that takes two parameters, one is Queue and other is int n, then I want to use stack and/or queue to
I need a method that takes two parameters, one is Queue and other is int n, then I want to use stack and/or queue to reverse the order of n elments in Queue instance. I don't want to use recursion. I want the reverse class with method taking queue and n as parameters and a main method. I want stack class with array implementation with push and pop methods and Queue class with linkedlist implementation with methods deQueue and enQueue . I need a stack class with raw array Also need time and space complexity of the algorithm.
For example: n=4 Original
Queue Contents: 1 3 6 7 2 1 390
New Queue Contents: 1 3 6 7 9 3 1 2
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
