Stacks and Queues


Stacks and Queues

Stacks and queues are linear data structures that follow a particular order to add or remove nodes.

What is a Stack?

linear data type with a constant capacity. It follows a particular order for adding or removing elements like FILO and LIFO Last In First Out (LIFO) or First In Last Out (FILO).

The implementation of stacks is easy. The functionality depends on the pop and push method, The pop method removes or deletes elements from the stack, while the push method adds items to the stack.

When an element is inserted into a stack, it takes the top position and the variable storing this position points to the number below it. The top variable should be updated anytime an element is inserted or removed from it. as you when you peek, you should see the top node value.

stack

What is a Queue?

A linear structure that follows a First In First Out (FIFO) order, but the functionality is different in how elements are removed. Queues are open from both sides: one side for inserting data enqueue, and the other end for removing data dequeue. A stack is only open from one end.

stack


   

Get back to EMAM’S HOMEPAGE

I have created this page as a part of my project using Github, Please visit my profile, I will be more than happy to hear from you all.                       © Emam Shararah 2021