Explore tens of thousands of sets crafted by our community.
Stack vs Queue
8
Flashcards
0/8
Peek/Front
Stack: Retrieves the top element without removing it. Queue: Retrieves the front element without removing it.
Top
Stack: Returns reference to the top element. Queue: Not applicable (Queue interfaces typically don't have a 'Top' operation).
Size
Stack: Returns the number of elements currently in the stack. Queue: Returns the number of elements currently in the queue.
Push/Add
Stack: Adds an element to the top. Queue: Adds an element to the end.
Overflow
Stack: Happens when trying to add an element to a full stack. Queue: Happens when trying to add to a full queue.
Underflow
Stack: Occurs when trying to remove an element from an empty stack. Queue: Occurs when trying to dequeue from an empty queue.
Pop/Remove
Stack: Removes the element from the top. Queue: Removes the element from the front.
IsEmpty
Stack: Checks if there are no elements in the stack. Queue: Checks if there are no elements in the queue.
© Hypatia.Tech. 2024 All rights reserved.