This is a C data structure question Please use C language th

This is a C data structure question. Please use C language, thank you very much!What would be the contents of queue Q after the following code is exe- cuted and the following data are entered?

1 Q = createQueue
2 loop (not end of file)

     1 read number

     2 if (number not 0)

           1 enqueue (Q, number)

      3 else

           1 x = queuerear (Q)

           2 enqueue (Q, x)

      4 end if

3 end loop

The data are: 5, 7, 12, 4, 0, 4, 6, 8, 67, 34, 23, 5, 0, 44, 33, 22, 6, 0.

Solution

Input Data : 5, 7, 12, 4, 0, 4, 6, 8, 67, 34, 23, 5, 0, 44, 33, 22, 6, 0.

1. Create Queue : Empty queue

Read 5

Queue contains : 5 (As if condition is true : 5 is not 0)

Read 7

Queue contains : 5<--7 (As if condition is true : 7 is not 0)

Read 12

Queue contains : 5<--7<--12 (As if condition is true : 12 is not 0)  

Read 4

Queue contains : 5<--7<--12<--4 (As if condition is true : 4 is not 0)  

Read 0

x = 4

enQueue(Q,4)

so Queue contains : 5<--7<--12<--4<--4 (As else condition is true)

Read 4

  Queue contains : 5<--7<--12<--4<--4 <--4

Read 6

Queue contains : 5<--7<--12<--4<--4 <--4<--6

Read 8

Queue contains : 5<--7<--12<--4<--4 <--4<--6<--8

Read 67

Queue contains : 5<--7<--12<--4<--4 <--4<--6<--8<--67

Read 34

Queue contains : 5<--7<--12<--4<--4 <--4<--6<--8<--67<--34

Read 23

Queue contains : 5<--7<--12<--4<--4 <--4<--6<--8<--67<--34<--23

Read 5

  Queue contains : 5<--7<--12<--4<--4 <--4<--6<--8<--67<--34<--23<--5

Read 0

x = 5

enqueue(Q,5)

Queue contains : 5<--7<--12<--4<--4 <--4<--6<--8<--67<--34<--23<--5<--5

Read 44

Queue contains : 5<--7<--12<--4<--4 <--4<--6<--8<--67<--34<--23<--5<--5<--44

Read 33

Queue contains : 5<--7<--12<--4<--4 <--4<--6<--8<--67<--34<--23<--5<--5<--44<--33

Read 22

Queue contains : 5<--7<--12<--4<--4 <--4<--6<--8<--67<--34<--23<--5<--5<--44<--33<--22

Read 6

Queue contains : 5<--7<--12<--4<--4 <--4<--6<--8<--67<--34<--23<--5<--5<--44<--33<--22<--6

Read 0

x = queuerear(Q)

x = 6

enqueue(Q,6)

  

Queue contains : 5<--7<--12<--4<--4 <--4<--6<--8<--67<--34<--23<--5<--5<--44<--33<--22<--6<--6

Reached end of file so reached out of the loop .

Final Queue Contents :  5<--7<--12<--4<--4 <--4<--6<--8<--67<--34<--23<--5<--5<--44<--33<--22<--6<--6

  

This is a C data structure question. Please use C language, thank you very much!What would be the contents of queue Q after the following code is exe- cuted and
This is a C data structure question. Please use C language, thank you very much!What would be the contents of queue Q after the following code is exe- cuted and

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site