4.2.2 - FoDS (Queues) Flashcards

1
Q

What type of data structure is a Queue, and what does the term used to describe it mean

A

FIFO (First in First out)
- Meaning the first item to enter the queue is the first to leave the queue

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

What are the three different types of queues

A
  • Linear
  • Circular
  • Priority
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the features of a linear queue

A
  • elements are added at the rear and removed from the front
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the disadvantage of linear queues

A
  • Inefficient as space is wasted when elements are dequeued.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are the features of a circular queue

A
  • Queue where the last position connects to the first, allowing space reuse. Prevents wasted space from dequeued elements.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the advantage of circular queues

A
  • allows space reuse when items are dequeued
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are the features of a priority queue

A

Elements are dequeued based on priority instead of arrival order.

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

How many pointers do queues have and where are they placed

A
  • 2 placed at the front and back of the queue
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How do you remove an item in the middle of a queue

A
  • You must first remove all of the items preceding it in the queue
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are the 4 key functions of a queue

A
  • Add
  • Remove
  • Check if empty
  • Check if Full
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How do you add items to the back of the queue

A
  • First check to see that the queue is not full
  • If full report an error and stop
  • Increment the back pointer and stop
  • Insert new data into the location pointed to by the back pointer
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How do you remove items from the front of the queue

A
  • First check to see that the queue is not empty
  • If empty report an error and stop
  • Copy the data pointed by the front pointer (item to be deleted)
  • Increment the front pointer and stop
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

When a circular queue is empty where do the front and back pointer point

A

To the same memory location

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

What is distinct about circular queues

A

When data items are added only the back pointer is modified

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

When is a circular queue full

A

When the back pointer points to the data location one less than the front pointer

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

When items in a priority queue have the same priority how are they treated

A
  • The same as in a normal linear queue