What is the outputs of the following pseudocode where num1 n

What is the outputs of the following pseudocode, where num1, num2, num3, are integer variables? num1 = 5 num2 = 1 num3 = 4 aQueue.enqueue(num2) aQueue.enqueue(num3) aQueue.dequeue() aQueue.enqueue(numl-num2) aQueue.dequeue(num2) aQueue.dequeue(num2)

Solution

num1 = 5

num2 = 1

num3 = 4

aQueue.enqueue(num2) //Will add 1 to the queue. So, now the queue will hold the value 1.

aQueue.enqueue(num3) //Will add 4 to the queue. So, now the queue will hold the values 1 4.

qQueue.dequeue() //Will remove the first element from the queue. So, now the queue will hold the value 4.

aQueue.enqueue(num1 - num2) //Will add 5-1 = 4 to the queue. So, now the queue will hold the values 4 4.

aQueue.dequeue(num1) //Will remove the first element from the queue, and store in num1. So, now the queue will hold the values 4. And num1 is updated to 4.

aQueue.dequeue(num2) //Will remove the first element from the queue, and store in num2. So, now the queue will be empty. And num2 is updated to 4.

Now, printing num2 followed by num1 followed by num3 will print the line 4 4 4 as output.

 What is the outputs of the following pseudocode, where num1, num2, num3, are integer variables? num1 = 5 num2 = 1 num3 = 4 aQueue.enqueue(num2) aQueue.enqueue(

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site