What is the first step in a reliable programming problem-solving process?
Identify the required inputs, outputs, rules, and constraints before designing a solution.
Study 9 Programming Problem-Solving Techniques with 12 free online flashcards. Review key terms, definitions, and concepts with this interactive flashcard deck.
What is the first step in a reliable programming problem-solving process?
Identify the required inputs, outputs, rules, and constraints before designing a solution.
Why decompose a programming problem?
Decomposition breaks a complex problem into smaller tasks that can be solved independently.
What does a variable’s type determine?
A variable’s type determines which operations are meaningful. The string "87" is text, not automatically the integer 87.
Why should grade thresholds be checked from largest to smallest?
Check the largest threshold first because the first true branch executes and prevents later branches from being reached.
When should you use `for` versus `while`?
Use a `for` loop for each item in a known collection; use a `while` loop when repetition depends on a condition.
What is a good design principle for a method?
A method should generally package one clear responsibility and communicate through parameters and a return value.
What do classes and instances represent?
A class bundles related state and behavior; instances represent particular objects created from that design.
When is inheritance preferable to composition?
Inheritance is appropriate for a genuine “is-a” relationship; composition is clearer when one object merely uses or contains another.
What invariant does `best_student` maintain?
After each iteration, `best` refers to the highest-scoring student examined so far.
What is `total` after tracing the values [3, 8, 2]?
The final value of `total` is 10 because the loop adds the even values 8 and 2, but not 3.
How do syntax, runtime, and logic errors differ?
A syntax error prevents parsing; a runtime error occurs during execution; a logic error runs but produces the wrong result.
What does boundary-value testing target?
Boundary-value testing focuses on edge cases such as 0, 1, the maximum allowed value, and values just outside the valid range.