A stack (English: stack), also known as a stack or stack, is an abstract data type in computer science that allows only one end of an ordered linear data collection (called The top of the stack (English: top) performs operations of adding data (English: push) and removing data (English: pop).
So it operates according to the principle of LIFO (Last In First Out).
Often compared to another ordered linear data collection queue.
Stacks are often implemented with one-dimensional arrays or linked lists.
Operations
The stack uses two basic operations:
Push (push) and pop (pop) ):
● Push: Put data on the top of the stack, and move the top of the stack to the newly placed data.
● Pop-up: Remove the data at the top of the stack, and move the top of the stack to the next piece of data after removal.
Features
Basic features of the stack:
● First in, last out, last in, first out.
● Except for the head and tail nodes, each element has a predecessor and a successor.
The above is the detailed content of what is stack. For more information, please follow other related articles on the PHP Chinese website!