4, Toad's data structure notes four stacks and queue definition
This famous article: " life should be like a candle, from the top to the end, has always been bright." "
Learning stacks and queues today. From the second study, we know that it is actually a linear table.
Let's look at the definition first.
Welcome reprint, Reproduced please indicate the source:
1. Stack
Stack, aka Stacks, is a linear table in which operations are limited . The limitation is that only one end of the table is allowed to insert and delete operations. This end is called the top of the stack, and the opposite end is called the bottom of the stack. Inserting a new element into a stack, also known as a stack, a stack, or a stack, is to put a new element on top of the stack, making it a new stack top element, deleting an element from a stack, or making a stack or fallback, by removing the top element of the stack and making its adjacent elements a new stack top element. There are two kinds of storage representations of stacks, namely sequential stacks and chain stacks.
2. Queues
A queue is a special linear table , except that it allows for deletion only at the front end of the table (front), but in the back-end (rear) of the table, and, like the stack, the queue is a linear table with limited operations. The end of the insert operation is called the tail of the queue, and the end of the delete operation is called the team header.
2.1 Sequential queues
To establish a sequential queue structure, you must statically allocate or dynamically request a contiguous amount of storage space and set up two pointers for management. One is the team head pointer front, which points to the team head element, and the other is the tail pointer rear, which points to where the next enqueued element is stored
2.2 Loop Queue
In the actual use of the queue, in order to make the queue space can be reused, the use of the queue is often slightly improved: regardless of the insertion or deletion, once the rear pointer 1 or the front pointer increases by 1 when the allocated queue space is exceeded, let it point to the starting position of this continuous space.
4, Toad's data structure notes four stacks and queue definition