Queue And Stack Flashcards

1
Q

What is a Queue?

A

Is a first in first out (FIFO) data structure

  • First one added is the first one out
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a Stack?

A

Is a last in first out (LIFO) data structure

  • Last one added is the first one out
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Show me how to implement a Queue

A

import java.util.LinkedList;
import java.util.Queue;

Queue<Integer> queue = new LinkedList<>();</Integer>

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

Show me how to implement a Stack

A

import java.util.Stack;

Stack<Integer> stack = new Stack<>();</Integer>

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

Difference between a queue and a priority queue?

A

Queue is based on first in first out, elements are added to the queue based on the insertion

Priority queue sorts them in some way

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