I'll directly jump up to stack later on I will post remaining things.As you know how line works i.e if we consider a line for bank so, how does people stand there, new person joins from the last and person standing at the first position withdraws or deposit the money as per his convience and leave the line.
So same happens in Stack.It uses Last In First Out pattern i.e LIFO, where the data is inserted at the last point and data is removed from start.In the below diagram we can see that the red block is inserted at the last and white one at the first but while removing the white block comes out last and the red one first so, this is how it follows the pattern of LIFO.
After this I'll tell you what is queue and next we will compare this both things to understand where this both data structure is use.
If any queries regarding stack kindly post it.I'll help you to clarify it well.
So same happens in Stack.It uses Last In First Out pattern i.e LIFO, where the data is inserted at the last point and data is removed from start.In the below diagram we can see that the red block is inserted at the last and white one at the first but while removing the white block comes out last and the red one first so, this is how it follows the pattern of LIFO.
After this I'll tell you what is queue and next we will compare this both things to understand where this both data structure is use.
If any queries regarding stack kindly post it.I'll help you to clarify it well.

No comments:
Post a Comment