Lists, Iterators, Deques, Bad Vector Usage Flashcards

1
Q

What do you use to traverse a list

A

an iterator

list <type>::iterator lit;
list <type>::const_iterator lit;</type></type>

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

A list allows for which insertion and deletion methods

A

push front, push back
pop front, pop back

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

To traverse a data structure in reverse order using an iterator you have to use

A

rbegin and rend

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

T/F You can insert into vectors, too, but you should not

A

True. This is due to its run time complexity being O(n^2)

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

A dequeue stands for a

A

double ended queue

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

A dequeue behaves like a vector with the proviso that

A

you can insert or delete from either end of the dequeue with high efficiency

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

When should i use a vector?

A

When you are either simply accessing n elements, or if you are calling only push_back / pop_back

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

When should i use a dequeue

A

If you want to call push_front / pop_front in addition to push_back / pop_back

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

When should i use a list

A

If you want to insert and delete elements from the middle of the data structure

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