Algorithms and Programming Flashcards
7 cards from real APCSP practice questions. Tap to flip, then mark Knew It or Still Learning โ missed cards come back until you master them.
Read the first 7 Algorithms and Programming flashcards as text
Which of the following best describes an undecidable problem in computer science?
Answer: A problem for which no algorithm can always produce a correct yes/no answer
An undecidable problem is one for which no algorithm can be written that will always correctly determine a yes or no answer for all possible inputs.
A programmer writes a procedure that calls itself. What is this technique called?
Answer: Recursion
Recursion is a programming technique where a procedure calls itself to solve smaller instances of the same problem.
What is the result of evaluating the Boolean expression: NOT (TRUE AND FALSE)?
Answer: TRUE
TRUE AND FALSE evaluates to FALSE, and NOT FALSE evaluates to TRUE.
A list contains [3, 7, 1, 9, 4]. After one pass of a selection sort (finding and placing the minimum), what does the list look like?
Answer: [1, 7, 3, 9, 4]
Selection sort finds the minimum (1) and swaps it with the first element (3), yielding [1, 7, 3, 9, 4].
Which of the following is an example of a heuristic approach to solving a problem?
Answer: Using a 'good enough' approximation strategy when an exact solution is impractical
A heuristic is a problem-solving approach that finds an approximate solution quickly when finding the exact solution would be too time-consuming.
In a programming language, what does the MOD operator return?
Answer: The remainder after integer division
The MOD operator returns the remainder after dividing one integer by another (e.g., 17 MOD 5 = 2).
Which traversal strategy visits all neighbors of a node before moving to the next level in a graph or tree?
Answer: Breadth-first search
Breadth-first search (BFS) explores all nodes at the current depth before advancing to nodes at the next depth level.