Question: Lab 4 CSC 326 Data Structures Stack and Queue Based on Linked Nodes Queues 1. Assume you have a stack S of inegers,and a queue
Lab 4 CSC 326 Data Structures Stack and Queue Based on Linked Nodes Queues 1. Assume you have a stack S of inegers,and a queue of integers &. Draw a picture of S and Q after the following operations: 1 pushStack (S, 3) 2 pushStack (s, 12) 3 enqueue (Q, 5) 4 enqueue (Q, 8) 5 popStack (S, x) 6 pushstack (s, 2) 7 enqueue (x) 8 dequeue , Y) 9 pushStack (S, x) 10 pushStack (s, y) Determine the elements stored in queues e1, 02, and stack S, after the execution of the following program segment: 2. IS = createStack 2 Q1-createQueue 4 enqueue (Q1, 5) 5 enqueue (Q1, 6) 6 enqueue (Q1, 9) 7 enqueue (Q1. 0) 9 enqueue (01, 5) 10 enqueue (Q1, 0) 11 enqueue (Q1, 2) 12 eoqueue (01, 6) 13 loop (not emptyQueue (01)) 1 dequeue (Q1, x) 2 if (x0) z-0 2 loop (not emptystack (S)) 1 popStack (S, sy) 3 end loop 4 enqueue (02, 2) 3 else 1 pashstack (s, x) 4 end if 14 end loop
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
