Question: P3.1. Consider an initially-empty stack S and the sequence of operations push(S,4),pUSH(S,19),pop(S),push(S,2),pop(S),pop(S),pUSH(S,9). Illustrate the result of each operation (clearly indicate the content of the stack

P3.1. Consider an initially-empty stack S and the sequence of operations push(S,4),pUSH(S,19),pop(S),push(S,2),pop(S),pop(S),pUSH(S,9). Illustrate the result of each operation (clearly indicate the content of the stack after the operation and, in case of a pop, the value returned by the operation). P3.2. Consider an initially-empty queue Q and the sequence of operations ENQUEUE (Q,4), ENQUEUE (Q,19), DeQuede (Q), ENQUEUE (Q,2), DEQUEUE (Q), DEQUEUE (Q), ENQUEUE (Q,9). Illustrate the result of each operation (clearly indicate the content of the stack after the operation and, in case of a DEQUEUE, the value returned by the operation). P3.3. Consider bags of values B1 and B2. The SerUNion operation takes bags B1 and B2 and returns a bag holding all values originally in B1 and B2 (possibly destorying B1 and B2 in the process). Provide a data structure to represent B1 and B2 such that SETUNION can be implemented in constant time
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
