Queues

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/29

flashcard set

Earn XP

Description and Tags

Flashcards about Queues and Priority Queues in Java

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

30 Terms

1
New cards

What is a queue?

A waiting line that grows by adding elements to its end and shrinks by taking elements from its front.

2
New cards

What does FIFO stand for in the context of queues?

First In/First Out

3
New cards

What are the essential operations for managing a queue?

clear(), isEmpty(), enqueue(el), dequeue(), front()

4
New cards

What happens when you try to dequeue or front an empty queue?

Throws an EmptyQueueException

5
New cards

Give three direct applications of queues

Waiting lists, Access to shared resources, Multiprogramming

6
New cards

Give two indirect applications of queues

Auxiliary data structure for algorithms, Component of other data structures

7
New cards

In what order does a Queue process its data?

First In First Out order

8
New cards

How can a queue be used to implement a round-robin scheduler?

Repeatedly dequeue, service, and enqueue elements

9
New cards

How does Round-robin scheduling work in operating systems?

Assigns time slices to each process in equal portions and in circular order, handling all processes without priority.

10
New cards

What two variables are required to keep track of the queue in an Array-based queue?

Front and last

11
New cards

What does isFull() do in the ArrayQueue class?

Returns whether the queue is full

12
New cards

What does isEmpty() do in the ArrayQueue class?

Returns whether the queue is empty

13
New cards

When is grow() called in Array implementation of queues?

Doubles the size of the array and copies elements

14
New cards

What does enqueue(Object x) do?

Adds an element to the end of the queue

15
New cards

What does front() do in the array implementation of a queue?

Returns the first element in the queue without removing it

16
New cards

What does dequeue() do in the array implementation of a queue?

Removes and returns the first element in the queue

17
New cards

In a linked list implementation of a queue, what are the two key node pointers?

head and tail

18
New cards

How do you enqueue an item in a linked list implementation of a queue?

Adds a new node at the tail

19
New cards

How do you dequeue an item in a linked list implementation of a queue?

Removes the head node

20
New cards

What is CircularQueue?

A Java interface that extends the Queue ADT with a new rotate( ) method.

21
New cards

What does rotate() do in circular queues?

Move the first element to the end of the queue

22
New cards

What operations are supported by a double-ended queue (Deque)?

Insert and delete at both the front and back

23
New cards

Name the methods for updating or modifying a Deque?

addFirst(e), addLast(e), removeFirst(), removeLast()

24
New cards

What accessor methods are commonly included in a Deque ADT?

first(), last(), size(), isEmpty()

25
New cards

How do priority queues differ from regular queues?

Breaks the FIFO rule by dequeuing elements based on assigned priority

26
New cards

How do elements get dequeued according to their priority queue position?

Elements are dequeued according to their priority and their current queue position

27
New cards

How does enqueue(float x) work in the array implementation of a priority queue?

Elements are inserted into the array in sorted order based on their priority

28
New cards

What does public float front() in the array implementation of priority queue do?

Return the element with the hightest priority

29
New cards

What does public float dequeue() in array implementation of priority queues do?

Removes and returns the element with the highest priority

30
New cards

Summary of behaviour of priority queues

In priority queues, elements are dequeued according to their priority and their current queue position.