Stacks and Queues Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What is a queue?

A

A First In First Out (FIFO) linear data structure that maintain the order of the data

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

What is at the front an back of queues?

A

Front pointer and a back pointer / head/tails pointer

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

What should be considered before enqueueing or dequeuing an item?

A

If the queue is full (queue overflow) or if the queue is empty (queue underflow)

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

Why is using arrays to implement a queue a problem?

A

Both the back and front pointers are moving in the same direction as items are added and removed - array will quickly run out of space

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

How to we solve the problem caused by implementing a queue using an array?

A

Cycle the back pointer to the front of the array when it reaches the end

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

An example of a queue

A

Transferring data between processors and printers - process scheduling

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

What is a stack?

A

A Last In First Out (LIFO) data structure - the last item to be pushed onto the stack must be the first item to be popped off

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

What is at the top of a stack?

A

A stack pointer

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

What should be considered before pushing or popping an item?

A

If the stack is full (stack overflow) or if the stack is empty (stack underflow)

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

An example of a stack

A

Keeping track of user inputs for undo operations

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