Queues Flashcards

1
Q

Queues

The queue uses a first-in-first-out policy. FIFO

When you delete an item from the list, it will be the f______ item (the head), the one that has been there the longest.

When you want to insert an item into a queue, it goes to the end of the queue (the t______).

A

first
tail

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

Queues - Operations

The insert operation is called = e__________
The delete operation is called = dequeue

Both operations take O( ) time

A

enqueue
1 = constant time

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

Pointers

Queues have two pointers. The first one points to the head (Q.head) of the queue.
The second pointer(O.tail) points to the empty box after the l______ e_______ in the queue.
That is why we can only have n-1 elements in a queue.
We need a space at the end for the Q.tail pointer!

A

last element

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

Pointers Continued

When both pointers are pointing to the same element (Q.head = Q.tail), this list is e__________.

When both pointers are at pointing at the empty space at the end of the list (Q.head = Q.tail + 1)
or
The Q.head =1 and Q.tail = Q.length
the list is empty.

A

empty

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