Stacks and queues stack and queue
Stacks (Stack):
The stack is also a special linear table, which is a last-in, first-out (LIFO) structure.
A stack is a linear table that restricts insert and delete operations only at the end of the table, and the footer is called the top of the stack, and the table header is called the bottom of the stack (bottom).
The physical storage of stacks can use sequential storage structures, or they can use chained storage structures.
Queuing (queue):
A queue is a linear table that restricts all inserts to be made only at one end of the table, while all deletions are made at the other end of the table.
The one end of the table that allows insertion is called the tail of the queue (Rear), and the one end that allows deletion is called the team header (Front).
The operation of the queue is performed on a first in, out (FIFO) basis.
The physical storage structure of a queue can be stored sequentially or chained to a storage structure.
Both the stack and the queue maintain a member variable that is used to store the stack or the elements in the queue. This member variable is typically implemented using LinkedList, and the stack or queue method is implemented based on the LinkedList method.
Java record -51-stacks and queues