Queue Flashcards

1
Q

A queue is structured in a…

A

FIFO(First in first out)

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

What does the dequeue method do?

A

Removes data from the front of the queue

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

What does the enqueue method do?

A

Adds a data item to the rear end of the queue

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

What does first() operation do?

A

Returns the data item at the front of the queue without removing it

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

What does the isEmpty method do?

A

Determines weather the queue is empty

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

What does the size method do?

A

Returns a string representation of the queue

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

What does the toString method do?

A

It returns a string representation of the queue

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

What 3 things is needed to implement a queue?

A
  1. A data structure to hold the data items
  2. A way to indicate the front of the queue
  3. A way to indicate the rear of the queue
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How do you implement a linked list implementation of a queue?

A

We need 2 pointers, front, rear, and one variable called count to store the number of data items

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

What 2 cases are mostly considered when dealing with a linked list? Enqueue operation

A
  1. The queue is empty
  2. The queue is not empty
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What 3 cases are considered for the Dequeue operation in a linked list?

A
  1. The queue is empty
  2. the queue has one data item
  3. The queue has more than 1 data item
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How would a queue be implemented using an array?

A

Using 2 variables: front = 0 and count = number of data items

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

2 cases to consider using an array and the enqueue operation?

A
  1. The array is full
  2. The array is not full
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What 2 cases to consider for the dequeue Operation and using an array?

A
  1. The queue is empty
  2. The queue is not empty
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What do we need to keep track of when implementing a queue as a circular array?

A

We need to keep track of the front data item and the rear data item

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

What must one take into account when using the enqueue operation in a circular array?

A

The value of the rear is incremented but it needs to loop back to index 0

17
Q

What line of code is used to loop back to the index 0

A

rear = (rear + 1) % queue.length

18
Q

What is a bounded queue?

A

a queue with a length that does not exceed a specified maximum value

19
Q

What is an unbounded queue?

A

is a queue with a length that can grow indefinitely

20
Q

True or False.
If the maximum length is negative it is bounded.

A

False. It is unbounded

21
Q

True or False.
If the maximum length is positive than it is unbounded.

A

False. It is bounded

22
Q

What are the advantages of a circular array?

A

We do not need to shift items when performing a dequeue operation.

23
Q

Last index in a circular array is

A

n - 1

24
Q
A