Queue Flashcards

1
Q

Is Queue Random or Sequential Access?

A

Sequential

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

A Queue is a data structure in which we add elements and remove elements according to LIFO or FIFO?

A

FIFO. First In, First Out.

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

What is a real life analogy of a Queue.

A

An actual queue of people. The first one to join the queue is the first one to leave the queue.

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

The back of a Queue is also called the…

A

Tail

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

The front of a Queue is also called the…

A

Head

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

We add elements to the …. of the Queue.

A

Back or Tail

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

We remove elements from the …. of the Queue.

A

Front or Head

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

What method do we use to add an element to a Queue?

A

Enqueue

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

What method do we use to remove an element from a Queue?

A

Dequeue

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

What are the four fairly standard Queue methods?

A

enqueue, dequeue, peek, contains

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

What does the peek() method do?

A

It returns the element at the front/head of the queue without removing it from the Queue.

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

What does the contains() method do?

A

Returns whether or not the Queue contains an element.

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

What is the BigO for ACCESSING an element in a Queue?

A

O(n). Worst-case the element you want will be at the tail of the queue.

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

What is the BigO for SEARCHING an element in a Queue?

A

O(n). Linear Search.

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

What is the BigO for INSERTING an element in a Queue?

A

O(1)

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

What is the BigO for DELETING an element in a Queue?

A

O(1)

17
Q

What are some use cases for Queues?

A

Job Scheduling

Printer Queuing