Given the initial state for myQueue: Show its final state below after the follow
ID: 3779275 • Letter: G
Question
Given the initial state for myQueue: Show its final state below after the following commands have been executed: myQueue. enqueue (myQueue. dequeue))); myQueue. enqueue myQueue. dequeue))); myQueue.enqueue(myQueue.dequeue()); Given the initial state for myQueue Show its final state below after the following commands have been executed: double temp = myQueue.dequeue(); myQueue.enqueue(myQueue.dequeue()); myQueue.enqueue(temp); Given the initial state for myQueue: Explain what is wrong with the following code: while(!myQueue.iaEmpty()) {myQueue.enqueue(myQueue.dequeue());}Explanation / Answer
Answer:
8)
i)myQueue.enqueue(myQueue.dequeue());----------->0.3
ii)myQueue.enqueue(myQueue.dequeue());---------->0.4
iii)myQueue.enqueue(myQueue.dequeue());--------->0.5
9)
i)myQueue.enqueue(myQueue.dequeue());----------->0.3
ii)myQueue.enqueue(temp);--------->0.4 0.5
10)
The line while(!myQueue.isEmpty()) is wrong with the given code it must be while(myQueue.isEmpty()) because we can only insert the elements if the queue is empty otherwise insertion of elements is not possible.
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.