Queue 

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play

1/15

encourage image

There are no tags or description

Looks like no tags are added yet.

16 Terms

1
New cards

FIFO

First In, First Out; a principle where the first element added to a queue is the first one to be removed.

2
New cards

Queue Interface in Java

A set of methods from the java.util package used to implement queues in Java.

3
New cards

LinkedList

A class in Java used to instantiate a Queue object since interfaces cannot be instantiated.

4
New cards

collections.deque

A module in Python used to implement queues, imported with the statement `from collections import deque`.

5
New cards

Enqueue

The operation of adding a new item to the queue.

6
New cards

Java Enqueue Example

`Queue queue = new LinkedList(); queue.offer("Lisa");` - demonstrates how to add an item in Java.

7
New cards

Python Enqueue Example

`queue = deque([]); queue.append("Lisa")` - demonstrates how to add an item in Python.

8
New cards

Dequeue

The operation of removing the head (first element) of the queue.

9
New cards

Java Dequeue Example

`poll();` - method used to remove the head of the queue in Java.

10
New cards

Python Dequeue Example

`popLeft()` - method used to remove the head of the queue in Python.

11
New cards

Peek

The operation of retrieving the head of the queue without removing it.

12
New cards

Java Peek Example

`peek();` - method used to retrieve the head of the queue in Java.

13
New cards

Python Peek Example

`queue_name[0];` - retrieves the head of the queue in Python.

14
New cards

isEmpty

A method to check whether the queue is empty.

15
New cards

Java isEmpty Example

`isEmpty();` - method used to check if the queue is empty in Java.

16
New cards

Python isEmpty Example

`if not queue:print("Queue is not empty");` - checks if the queue is empty in Python.