In Computer Science and programming, a data structure simply is how a particular set of data values is arranged, stored, and managed.
Going forward, I’d like you to think of the word ’stack’ in its literal sense. What comes to mind? A bunch of books well-arranged? Right. A pile of plates? Also right.
A stack consists of data items, and it allows one to insert or delete the item at the top end of the stack. The insert operation in the stack data structure is referred to aspush
while the delete operation is called pop
Stack operations happen at the top of the stack only, that is on the last element to be added
Last In, First Out, LIFO, is used to describe the order by which Stack operations are executed. The last data element to be added is the first element to be retrieved. Also, a new data element is added at the top of the stack.
#coding #data-structures #python #algorithms