Queues Flashcards

1
Q

What basis does a Queue use

A

A first in first out (FIFO)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

4 operations of a queue

A

Enqueue
Dequeue
IsEmpty
IsFull

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What does Enqueue do

A

Adds an item to the end of the queue

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What does Dequeue do

A

Remove and return the item from the front

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What does IsEmpty do

A

Checks if the queue is empty

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What does IsFull do

A

Checks if the queue is full

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are the 3 types of queues

A

Linear
Circular
Priority

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How are linear queues implemented

A

Can be used with a fixed array size
There will also be front and rear pointers that are the index values for the first and last item

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What does the front pointer do (in a linear queue)

A

Next item to be removed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What does the rear pointer do (in a linear queue)

A

The last item added

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Problem with a linear queue

A

Cannot add to a full queue or remove from an empty one
Need to specify the max size

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How does a circular queue work

A

If there are spaces in the front it will reuse them if the queue is full

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How can you check the number of items in a linear queue

A

(Rear - front) + 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What function would you use for the pointers in a circular queue

A

MOD function
pointer = (pointer+1) MOD queueSize

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How does a priority queue work

A

Some items are allowed to jump as when items are queued they will have a priority associated to them

How well did you know this?
1
Not at all
2
3
4
5
Perfectly