4.2.2 - FoDS (Queues) Flashcards

(17 cards)

1
Q

What type of data structure (FIFO OR LIFO) 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 is meant by a pointer

A
  • A reference to the location of stored data items in stacks and queues
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
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
4
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
5
Q

What is the disadvantage of linear queues

A
  • memory inefficient as, once the rear of the queue reaches the end of the array, no new elements can be added—even if there are empty spaces at the front—resulting in unused memory.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are the features of a circular queue

A
  • Circular queues treat the array as a circle, so when the rear reaches the end, it wraps around to the front if space is available.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
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
8
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
9
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
10
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
11
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
12
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
13
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
14
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
15
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
16
Q

When is a circular queue full

A

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

17
Q

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

A
  • The same as in a normal linear queue