88 969
Assignments Done
96.9%
Successfully Done
In July 2020

# Answer to Question #45179 in Other Programming & Computer Science for Golden

Question #45179
1. Suppose an initially empty stack S has performed a total of 25 push operations, 12 top operations, and 10 pop operations, 3 of which returned null to indicate an empty stack. What is the current size of S?

2. Suppose an initally empty queue Q has performed a total of 32 enqueue operations, 10 first operations, and 15 dequeue operations, 5 of which returned null to indicate an empty queue. What is the current size of Q?
1
2018-04-24T09:56:17-0400
1) For stack:
- Push – adds item to collection and increases size of stack
- Top – only returns last item from collection without removing it
- Pop – returns last item from collection and decrease size of stack
If 3 pop operations returned null then only 7 pop operations decrease size of stack. Current size of stack is 25 (push) - 7 = 18;
2) For queue:
- enqueue – adds item to collection and increases size of queue
- first – only first last item from collection without removing it
- dequeue – returns first item from collection and decrease size of stack

The same is for queue : Current size of queue is -> 32 – 10 = 22.

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Assignment Expert
24.04.18, 16:56