Big talk data structure VIII.: Sequential storage structure of queues (circular queues)

Source: Internet
Author: User

1. What is a queue?

Queues are linear tables that allow only inserts at one end and deletions at the other end.

2. Characteristics of the queue:

A queue is an advanced first-out linear table that allows the insertion of one end to be called the tail of the team, allowing the end of the deletion to be called the team head.

3. What is the shortage of queue order storage?

Using array-implemented sequential storage, when a queue operation is made, all elements need to move one bit forward, with very low performance.

4. What is a loop queue?

The sequential storage structure of a queue's end-to-end is called a circular queue.

As shown in the figure: Front remembers the bottom of the team header element, rear remembers the next element of the team tail element.

Attention:

1. Only by the equation Front=rear is unable to judge whether the team is empty or the team is full, so we agreed that when the queue head pointer front the next position in the tail pointer rear, the queue is "full", and when the queue is full, there is also an idle position in the array.

2. We can also set a flag variable flag, when (front = = Rear && flag = = 0) The queue is empty, when (front = = Rear && flag = 1) The team is listed full.

More Wonderful content: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/sjjg/

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.