Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. Suppose the following operations are performed on an empty static stack which

ID: 644147 • Letter: 1

Question

1. Suppose the following operations are performed on an empty static stack which has four spaces to store data. There is the order: push(45) - > push(23) - > pop(x) - > push(45) > push(33) > POPL) > push(23) - > push(24) - > pop(x) - >pop(x) - > pop(x) - > push(7). insert numbers in the following Figure 1 to show what will be stored in the static stack after the operations above have executed. Don't forget showing the exact position of top. 2. Suppose the following operations are performed on an empty static queue which has four spaces (queueSize - 4) to store data. There is the order: enqueue(45) - > enqueue(3) - > dequeue(x) - > enqueue(45) - > enqueue(33) - > dequeue(x) - > enqueue(23) - > enqueue(24) - > dequeue(x) - > dequeue(x) - > dequeue(x) - > enqueue(7). Insert numbers in the following Figure 2 to show what will be stored in the static stack after the operations above have executed. Don't forget showing the exact positions of front and rear.

Explanation / Answer

1.

   Sub 0 Sub 1 Sub 2 Sub 3 Sub 4 Sub 5 Sub 6

Top 23 45 33 45 24 45 7

45 45 45 23 45

45 45

45

2. Rear   

   Sub 0 : 23 45<-front

   Sub 1: 23<-front

Sub 2: 33 45 23<-front

   Sub 3:   45 23<-front

   Sub 4: 24 23 45 23<-front

   Sub 5: 23<-front

Sub 6: 7 23<-front