Chapter 4: Stacks and Queues Flashcards

1
Q

Why use stacks and queues?

A

They are programmer tools for in-memory storing of data that needs to be referenced sequentially, as it is encountered

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

How are stacks and queues more abstract than arrays?

A

They are arrays but through an interface of restricted access

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

What is the Big O complexity of pushing and popping an item onto a stack or queue?

A

O(1)

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

Priority queues are used for?

A

Finding the cheapest or shortest way to do something

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

Insertion for a priority queue implemented as an array

A

O(n) - insert item at top and sift to position

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