Queue (1).pdf - Queue Queue 2 First-in first-out(FIFO Queue First-in first-out(F I F O •A is a sequential organization of data first-outusing(LIFO)f i

Queue (1).pdf - Queue Queue 2 First-in first-out(FIFO Queue...

This preview shows page 1 - 14 out of 47 pages.

Queue
Image of page 1

Subscribe to view the full document.

Queue First -in first-out (FIFO) 24/01/1441 2
Image of page 2
Queue A is a sequential organization of data. Data is accessible using f i f o . The first data in the queue is the first data that is accessible by your program. you will explore the simplest type of queue, a fixed size , first in, first out queue using an array First -in first-out (F I F O) 24/01/1441 3
Image of page 3

Subscribe to view the full document.

A Simple Queue vs. Priority Queue A organizes items in a line where the first item is at the beginning of the line and the last item is at the back of the line. Each item is processed in the order in which it appears in the queue. A is similar to a simple queue in that items are organized in a line and processed sequentially. However, items on a priority queue can jump to the front of the line if they have priority. is a value that is associated with each item placed in the queue. 24/01/1441 4
Image of page 4
A Simple Queue vs. Priority Queue A items in a line without priority processed ( sequentially processes ) A has items with priority processes is a value that is associated with each item placed in the queue. 24/01/1441 5
Image of page 5

Subscribe to view the full document.

Queue Operations A queue is like a line of people waiting for a bank teller. The queue has a front and a rear . $ $ Front Back (Rear) 24/01/1441 6
Image of page 6
New people must enter the queue at the rear. The C++ queue class calls this a push , although it is usually called an enqueue operation. $ $ Front Queue Operations Back (Rear) 24/01/1441 7
Image of page 7

Subscribe to view the full document.

When an item is taken from the queue, it always comes from the front. The C++ queue calls this a pop , although it is usually called a dequeue operation. $ $ Front Queue Operations Back (Rear) 24/01/1441 8
Image of page 8