Week 7 Flashcards

1
Q

both are versatile data structures commonly used in the implementation of other, more complex data structures.

A

stacks and queues;

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

is a data structure in which only the last inserted element can be removed and accessed. Think about stacking plates on a table. To get to the bottom one, you must remove all the other ones on the top. This is a principle known as last in, first out (LIFO).

A

A stack

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

is great because it is fast. Since it is known that the last element is to be removed, the lookup and insertion happen in a constant time of O(1).

A

A stack

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

should be used over arrays when you need to work with data in the LIFO form where the algorithm needs to access only the last-added element. The limitation of —- is that they cannot access the non-last-added element directly like arrays can; in addition, accessing deeper elements requires you to remove the elements from the data structure.

A

Stacks

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

is also a data structure, but you can remove only the first added element. This is a principle known as first in, first out (FIFO).

A

A queue

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

is also great because of the constant time in its operations. Similar to a stack, it has limitations because only one item can be accessed at a time.

A

A queue

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

should be used over arrays when you need to work with data in the FIFO form where the algorithm only needs to access the first added element.

A

Queues

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