Answer to Question #45179 in Other Programming & Computer Science for Golden
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?
- 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!
Dear Naomi. Please find updated answer
Isn't 25-7 = 18 though? Why is the size of the Stack 16?