Data Structures Flashcards

1
Q

What is the purpose of Data Structures?

A

To store information, allocate data, and provide helpful methods / instance variables for users

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

What are Data Structures essentially?

A

Managed Pointers

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

What functionality does a Vector provide?

A

Dynamically growing storage

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

How do you declare a vector?

A

vector<generic> var = …;

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

What does vector.size() return?

A

The number of elements currently in the vector

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

What does action vector.push_back(value) perform?

A

It pushes the value to the back of the vector

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

What action does vector.pop_back() perform?

A

Erases and returns a copy of the last element in the vector

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

What action does vector.erase(vector.begin+index) perform?

A

Removes elements individually or in a range.

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

What provides the rules for standard implementation of data structures in C++?

A

Containers

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

What rules do containers require?

A
  • Default Ctor
  • copy Ctor
  • methods for empty, size, and capacity
  • iterators
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is an Iterator?

A

A class defined inside a data structure to traverse the data.

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

What is the one rule for an iterator?

A

It can move forward

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

What are the 3 main types of iterators?

A
  • ForwardIterator
  • BiDirectionalIterator
  • RandomAccessIterator
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What are the minimum operators in an iterator?

A
  • * (dereference)
  • ->
  • ==
  • !=
  • ++
  • =
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What method is used to increment an iterator 1 position? (++)

A

next(Iterator)

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

What method is used to increment an iterator multiple positions? (+=)

A

advance(iterator, int)

17
Q

Why do methods for Iterators work on Pointers?

A

Because Iterators are pointer like, and simply point to an object.