Reference no: EM13165756
represent my queue object as a parameter, It should return a reverse queue. it is suppose to take as a parameter an object of type Queue
, the queue class defined in the algs13
package, and that returns aQueue
object with the same elements as in the parameter queue but reversed. For instance, if the queue q1
contains the integer values 13, 15, 9, 10, and 25 (in that order), the following call:
q2 = reverseQueue(q1);
will result in q2
having the values 25, 10, 9, 15, 13 (in that order). I am just confused about how I should represent the parameter as a Queue. Here is what I dug up so far:
import algs13.Queue;
public class reverseQueue {
public static int[] readInts()
{
Queue <Integer> q = new Queue<Integer>();
int N = q.size();
int[] a = new int[N];
for(int i = 0; i < N; i++){
final int temp =