Ladies and gentlemen, crossing, the last time we were talking about an example of an expression evaluation, this example uses a stack, which we're talking about.
Brother: Queue. Gossip Hugh, words return to the positive. Let's talk C chestnuts together!
What we're saying here is that the queue is an abstract data structure that you don't have to think about too abstract, haha, actually it and our daily life
See the same queue. In any case, let's take an easy-to-understand example: Everyone has a line when they go on vacation.
The experience of buying tickets. The visitors were lined up in front of the window at the ticket office, selling tickets to the queue
Visitors, who bought tickets happily left the queue with tickets, and the tourists who had just arrived at the ticket line were waiting in the queue to buy
Tickets. In this case, the visitors are lined up in order to buy tickets next to the ticket line, which can be seen as a queue, a queue
Visitors can be seen as elements that are stored in the queue. Visitors who buy tickets leave the queue and can be seen as removing elements from the queue and want to
Visitors who purchase tickets are queued to be considered as inserting elements into the queue. I say, do you still think the queue is abstract? If you feel
Abstract words, the next trip to buy tickets to pay more attention to it.
Let's take a look at the characteristics of the queue:
1. The queue has a head and a tail. For example, a visitor who buys a ticket first can be seen as a queue head. The tourists who just lined up in the queue
Can be seen as the tail of the queue.
2. Removing elements from the queue can only be done at the head of the queue. For example, the visitor who buys the ticket in the example just now leaves the queue and can be seen from the team
The column header deletes an element.
3. Inserting elements into the queue can only be done at the end of the queue. For example, if you want to buy tickets in the queue, you can think of it as
Inserts an element into the queue.
4. The elements in the queue adhere to the "FIFO" rule. For example, the first line of visitors can buy tickets first.
Crossing, the text does not write code, the detailed code put in my resources, you can click here to download the use. This queue is
Implemented by sequential storage, specifically to the code that uses an array to act as a queue.
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 (22nd time: C-language Instance-queue one)