Question

Assume q passed into the function below is: q={10,9,8,7,6,5,4,3,2,1} What would be the resulting queue (q)...

Assume q passed into the function below is: q={10,9,8,7,6,5,4,3,2,1}

What would be the resulting queue (q) at the line below with the comment labeled //3.____

public Queue interChanger(Queue q){
Stack<Integer> st = new Stack<Integer>();

int size = q.size()/2;
for(int i = 1; i <= size; i++){

st.push(q.remove()); //1. ____________

}

while(!st.isEmpty()){

q.add(st.pop()); //2. ____________

}

for(int i = 1; i <= size; i++){

q.add(q.remove()); //3. ____________

}

for(int i = 1; i <= size; i++){

st.push(q.remove()); //4. ____________

}

while(!st.isEmpty()){

q.add(st.pop());    

q.add(q.remove()); //5. ____________

}   

return q;

}

67891054321

678910

12345678910

109876

0 0
Add a comment Improve this question Transcribed image text
Answer #1


A)  67891054321

Add a comment
Know the answer?
Add Answer to:
Assume q passed into the function below is: q={10,9,8,7,6,5,4,3,2,1} What would be the resulting queue (q)...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT