1. Basic properties of stacks and queues
- Stack is advanced after out; (like a bullet clip, a last-shot first)
- Queues are FIFO; (like waiting in line to buy ice cream, in order to take turns)
- Stack and queue in the implementation of the structure can have an array and a list of two forms;
(1) The array structure is easy to implement;
(2) The structure of the linked list is more complicated, because it involves a lot of pointer operation;
1.1 Basic operation of stack structure
(1) Pop operation; (eject)
(2) Top or peek operation;
(3) Push operation; (press stack)
(4) Size operation;
1.2 Basic operations of the queue
(1) The basic operation of the queue differs from the stack operation in that thepush operation joins the element in the team header, while the pop operation pops an element from the tail of the queue;
(2) The basic operation of the queue and stack is the operation of the Time Complexity O (1);
Special:
- Two-terminal queue structure: For the end can be pressed into and eject elements;
- Priority Queue structure: Determines the popup order of elements based on the priority value of the element, which is essentially a heap structure, not a linear structure;
Data structures and Algorithms (3)-----> Queues and Stacks