Stack and Queue

Hi Friends,

Now in this section, I am going to talk about Stack. Basically, stack works on the principle of LIFO(Last in First out) means the element which gets inserted in the stack Last will come out first. Here, there are two fundamental principles involved 1)Push and 2)Pop. Push is to insert the element on the stack and Pop to remove the same.

Below, in the snippet i have explained all the basic operations involved with Stack.

33rd

Now, lets cover Queue. Queues are opposite of Stack. Queues work on the principle of FIFO(First in First out). Here, also two basic operations are involved to insert(known as Enqueue) and remove(known as Dequeue). Lets see the same in action.

33rd

So, this was the stacks and queue. In the next section, will cover some other collection. Till then stay tuned and Happy Coding.

Thanks,
Rahul Sahay
Happy coding

This entry was posted in C# and tagged . Bookmark the permalink.