Question

Using Figure 10.1 as a model, illustrate the result of each operation in the sequence PUSH(S,...

Using Figure 10.1 as a model, illustrate the result of each operation in the sequence PUSH(S, 4), PUS(S, 1), PUSH(S, 3), POP(S), PUSH(S, 8), and POP(S) on an initially empty stack S stored in array S [1… 6].

0 0
Add a comment Improve this question Transcribed image text
Answer #1

ok we have a stack of size 6 which is initially empty.

1. operation push(s,4)

stack will look like

4

2)

push(s,1)

stack will look like

1

4

3)

push(s,3)

stack will look like

3

1

4

4)

pop(s)

stack will look like

1

4

5) push (s,8)

stack will look like

8

1

4

6)

pop(s)

stack will look like

1

4

Finally stack will have two values

1

4

Add a comment
Know the answer?
Add Answer to:
Using Figure 10.1 as a model, illustrate the result of each operation in the sequence PUSH(S,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT