Talk C Chestnut Bar (23rd time: C-language Instance-queue two)

Source: Internet
Author: User


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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.