Question

A. Starting with an initially empty stack, after 6 push operations, 3 pop operations, and 2...

A. Starting with an initially empty stack, after 6 push operations, 3 pop operations, and 2 push operations, the number of elements in the stack would be:

B. Starting with an initially empty queue, after 5 enqueue operations, 4 dequeue operations, and 6 enqueue operations, the number of elements in the queue would be:

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

A)

Initially stack is empty, after 6 push operations there will be total of 6 elements present in the stack

after 3 pop operations 3 elements will be removed from stack so 3 elements are remaining in the stack

and 2 push operations so 2 will be pushed into stack so total of 2+3=5 elements will be present in stack

B)

Initially queue is empty, after 5 enqueue operations there will be total of 5 elements present in the queue

after 4 dequeue operations 4 elements will be removed from queue so 1 element is remaining in the queue

and 6 enqueue operations so 6 will be inserted into queue so total of 6+1=7 elements will be present in queue

Add a comment
Know the answer?
Add Answer to:
A. Starting with an initially empty stack, after 6 push operations, 3 pop operations, and 2...
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