Question: HOMEWORK SET # 5 ( FOR EXTRA CREDIT ) ANSWER ALL QUESTIONS. Name: q , [ 6 pts ] The following operations are performed on

HOMEWORK SET #5(FOR EXTRA CREDIT)
ANSWER ALL QUESTIONS. Name: q,
[6 pts] The following operations are performed on a stack: PUSH A, PUSH B, PUSH C, POP, POP, PUSH D, PUSH E, POP, PUSH E, PUSH F, POP, POP, PUSH G
a. What does the stack contain after the PUSH G?
b. At which point does the stack contain the most elements? Without removing the elements left on the stack from the previous operations, we perform:
PUSH H, PUSH I, PUSH J, PUSH K, POP, PUSH L, POP, POP, POP, PUSH M, POP, POP, PUSH M
c. What does the stack contain now?
[6 pts] The input stream of a stack is a list of all the elements we pushed onto the stack, in the order that we pushed them.
The output stream is a list of all the elements that are popped off the stack, in the order that they are popped off.
a. What is the output stream from Exercise 1?
b. If the input stream is ZYXWVUTSR, create a sequence of pushes and pops such that the output stream is YXVUWZSRT.
c. If the input stream is YXW, how many different output streams can be created? List them down
HOMEWORK SET # 5 ( FOR EXTRA CREDIT ) ANSWER ALL

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!