What cycle should guide an integrated programming problem?
First understand requirements, represent the data, design the algorithm, implement in small parts, test cases, debug systematically, and evaluate correctness and efficiency.
Study 10. Integrated Problem-Solving Practice with 12 free online flashcards. Review key terms, definitions, and concepts with this interactive flashcard deck.
What cycle should guide an integrated programming problem?
First understand requirements, represent the data, design the algorithm, implement in small parts, test cases, debug systematically, and evaluate correctness and efficiency.
What is an algorithmic invariant?
An invariant is a statement that must remain true at a particular point in an algorithm, such as all items outside a search range being ruled out.
What does classify_number return for zero?
It returns "positive" when value > 0, "negative" when value < 0, and "zero" otherwise.
How does summarize_scores handle an empty list?
It returns 0, 0, None, avoiding division by zero and making empty-input behavior explicit.
What makes a password valid in the example?
Both conditions must be true: the password has at least eight characters and contains at least one digit.
Why does condition order matter in temperature_counts?
The order determines classification: elif is checked only if the preceding condition is false, so explicit boundaries prevent overlap or gaps.
What data structure suits a frequency table?
A mapping from each item to its count, because it directly represents the relationship and avoids parallel lists.
What defect is in the incorrect average function?
The denominator incorrectly uses len(value), where value is the last element. It should use len(values), with an empty-list check first.
How do you prevent a nonterminating search loop?
The loop must change a controlling variable or condition toward termination; in find_first_even, index += 1 is required when the value is odd.
What precondition does binary search require?
Binary search requires data sorted according to the same ordering used by its comparisons; otherwise, discarding half the range is unjustified.
What is linear search’s worst-case time complexity?
Linear search has worst-case time complexity O(n), because it may examine every element before finding the target or reaching the end.
Why is binary search O(log n)?
Binary search has worst-case time complexity O(log n), because each iteration reduces the remaining search range by about half.