Ladies and gentlemen, crossing, the last time we talked about the queue and its characteristics, and through examples to illustrate the queue, this time we continue to say
Queue, but what we're talking about is a chain-of-storage queue, which is not the same as the queue stored in the previous order. Gossip Hugh, Words return
Positive turn. Let's talk C chestnuts together!
The chained storage of a queue is implemented in code through a linked list. and defines a head node, which is used primarily to hold the queue's head and tail.
Information about the length of the queue. Our operations on the queue are essentially operations on the list, and the nodes in the queue can be seen as
Nodes in a linked list, into row (EnQueue) and dequeue (DeQueue) operations on the queue, can be thought of as inserting in a linked list
or delete the node operation. Just insert or delete to follow the queue "FIFO" features.
The biggest advantage of a queue's chained storage is that it doesn't need to know the length of the queue in advance,
Because, in the actual program, the use of more is through the chain storage implementation of the queue. In addition, it is more than the sequential storage implementation of the queue to
It is also convenient to live some things, such as into row and dequeue. Its space utilization is much higher than the sequential storage implementation of the queue. Imagine a
, a sequential container of length 10 (an array in the program), used only to hold a queue of length 3, significantly wasting 7 of the storage in the container
Space. Also, if the length of the queue exceeds the length of the sequential container, the length of the sequential container needs to be re-adjusted, otherwise it will be
Insufficient length, no space to store the entire queue.
Crossing, the text does not write code, the detailed code put in my resources, you can click here to download the use.
You crossing, we're going to talk about the queue here. I want to know what the following example, and listen to tell.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Talk C Chestnut Bar (23rd time: C-language Instance-queue two)