Logo
Pattern

Discover published sets by community

Explore tens of thousands of sets crafted by our community.

Stack vs Queue

8

Flashcards

0/8

Still learning
StarStarStarStar

Peek/Front

StarStarStarStar

Stack: Retrieves the top element without removing it. Queue: Retrieves the front element without removing it.

StarStarStarStar

Top

StarStarStarStar

Stack: Returns reference to the top element. Queue: Not applicable (Queue interfaces typically don't have a 'Top' operation).

StarStarStarStar

Size

StarStarStarStar

Stack: Returns the number of elements currently in the stack. Queue: Returns the number of elements currently in the queue.

StarStarStarStar

Push/Add

StarStarStarStar

Stack: Adds an element to the top. Queue: Adds an element to the end.

StarStarStarStar

Overflow

StarStarStarStar

Stack: Happens when trying to add an element to a full stack. Queue: Happens when trying to add to a full queue.

StarStarStarStar

Underflow

StarStarStarStar

Stack: Occurs when trying to remove an element from an empty stack. Queue: Occurs when trying to dequeue from an empty queue.

StarStarStarStar

Pop/Remove

StarStarStarStar

Stack: Removes the element from the top. Queue: Removes the element from the front.

StarStarStarStar

IsEmpty

StarStarStarStar

Stack: Checks if there are no elements in the stack. Queue: Checks if there are no elements in the queue.

Know
0
Still learning
Click to flip
Know
0
Logo

© Hypatia.Tech. 2024 All rights reserved.