CS 240 FINAL Flashcards

(10 cards)

1
Q

Q: What are the advantages of iterative solutions?

A

A: Use less memory, easier to write.

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

Q: What are the advantages of recursive solutions?

A

A: More elegant, easier to define, saves programmer time.

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

Q: What are the disadvantages of recursive solutions?

A

A: Use more resources, each call copies variables, less efficient.

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

Q: Name three types of STL members and give an example of each.

A

A:

Container: vector, stack, queue, list

Algorithm: sort(), max_element()

Iterator: Used to traverse containers like a pointer.

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

Q: What does Big-O measure?

A

A: The efficiency of an algorithm, focusing on time complexity as input grows.

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

Q: What is a major advantage of Big-O notation?

A

A: Helps compare time complexities among algorithms.

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

Q: What is a weakness of Big-O notation?

A

A: It’s not precise—doesn’t show actual performance or order-of-magnitude differences.

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

Q: What data structure uses Last-In, First-Out (LIFO)?

A

A: Stack
Example: var.push(); var.pop();

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

Q: What data structure uses First-In, First-Out (FIFO)?

A

A: Queue
Example: var.push(); var.pop();

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

Q: What are key vector operations in C++?

A

A: push_back(), pop_back(), reserve(), capacity(), size()

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