(Solved) : Data Structure Problem Question 4 Queue Stack Assume Two Adts One Queue Adt Following Stan Q34215602 . . .
Data structure problem
Question4: Queue &stack
Assume that we have two ADTs.
One is a Queue ADT with the followingstandard operations:
Queue CreateQueue(int x); //Creates aqueue with size = x;
void EnQueue(int x, Queue Q); //Insertan integer x to the queue Q.
int DeQueue(); //Removes a queueelement and returns it as a result.
The other is a Stack ADT with thefollowing standard operations:
Stack CreateStack(int x); //Creates astack with size = x;
void Push(int x, Stack S); //Insert aninteger x to the stack S.
int Pop(); //Removes the top elementof the stack and returns it as a result.
In addition, we also have a Playfunction below to call the Queue and Stack operations.
void Play( ) {
/* 1*/ Stack S=CreateStack(4);
/* 2*/ Queue Q=CreateQueue(4);
/* 3*/ EnQueue(2, Q);
/* 4*/ EnQueue(3, Q);
/* 5*/ EnQueue(1, Q);
/* 6*/ EnQueue(4, Q);
/* 7*/ Push(DeQueue( ), S);
/* 8*/ Push(DeQueue( ), S);
/* 9*/ EnQueue(Pop( ), Q);
/*10*/ EnQueue(Pop( ), Q);
/*11*/ EnQueue(DeQueue( ), Q);
}
Assume that the front (head) of thequeue is on the left. Please write the sequence of values stored inthe queue Q after lines 6, 8, 11 in Play() have been executed.
After line 6:
After line 8:
After line 11:
Expert Answer
Answer to Data Structure Problem Question 4 Queue Stack Assume Two Adts One Queue Adt Following Stan Q34215602 . . .
OR