Stacks and queues are special linear tables.
Stack: Only allow data to be added and deleted at one end, there is the principle of FIFO.
Inserting elements into the stack, removing elements from the top of the stack as a stack. The bottom element of the stack is the top element of the stack, and the top element of the stack is the top element.
Stacks are only allowed to increment and delete elements at the top of the stack.
The first-in-stack elements are at the bottom of the stack, and then on top of the stack.
Stacks can be implemented in the form of arrays. The stack is a restricted linear table, allowing only the deletion of elements at the top of the stack, insert operations.
Link Stacks:
The previous element's next point points to the element that was originally on top of the stack, and so on until the bottom of the stack.
Into the stack operation:
The stack operation:
Java inside the stack implementation:
Stack, an array-based sequential stack implementation, thread-safe.
LinkedList: is a double-line linked list structure, also has the operation of the stack, is the chain implementation of the stack, thread is unsafe.
Queue:
Specifies the direction in which data is entered and the direction to go, and the data in the queue is always first entered first.
The queue only allows elements to be deleted at the front end, and elements inserted on the backend.
Loop queue:
A queue that is connected to the end, the last element next to the first element.
The chained storage structure and implementation of the queue:
Insert Queue:
To remove a queue:
Queues in the Java collection:
After JDK 1.5, the queue interface represents a queue that provides methods for inserting, removing, and accessing.
Arrayblockingqueue,linkedblockingqueue,priorityqueue,concurrentlinkedqueue,synchronusqueue.
Arrayblockingqueue,linkedblockingqueue,concurrentlinkedqueue thread safety.
Two-way queue:
You can delete and insert elements on either side of the queue.
A two-way queue is a special linear table of queues and stacks.
Not finished, waiting for tomorrow to write, sleepy, sleep first
Stack and queue of data structures