CS 240 FINAL Flashcards
(10 cards)
Q: What are the advantages of iterative solutions?
A: Use less memory, easier to write.
Q: What are the advantages of recursive solutions?
A: More elegant, easier to define, saves programmer time.
Q: What are the disadvantages of recursive solutions?
A: Use more resources, each call copies variables, less efficient.
Q: Name three types of STL members and give an example of each.
A:
Container: vector, stack, queue, list
Algorithm: sort(), max_element()
Iterator: Used to traverse containers like a pointer.
Q: What does Big-O measure?
A: The efficiency of an algorithm, focusing on time complexity as input grows.
Q: What is a major advantage of Big-O notation?
A: Helps compare time complexities among algorithms.
Q: What is a weakness of Big-O notation?
A: It’s not precise—doesn’t show actual performance or order-of-magnitude differences.
Q: What data structure uses Last-In, First-Out (LIFO)?
A: Stack
Example: var.push(); var.pop();
Q: What data structure uses First-In, First-Out (FIFO)?
A: Queue
Example: var.push(); var.pop();
Q: What are key vector operations in C++?
A: push_back(), pop_back(), reserve(), capacity(), size()