A program prints "Even Positive" only if a number is both greater than 0 and divisible by 2, prints "Even Non-Positive" if it is divisible by 2 but not greater than 0, and otherwise prints "Odd Non-Positive." If the input is 0, what is printed?
What is Even Non Positive?
A programmer imports a library function that returns a random integer between 1 and 10 inclusive. The program calls the function twice and adds the results. What is the probability the sum is exactly 2?
What is 1/100?
An algorithm’s runtime doubles when the input size increases by 1. This growth pattern is best classified as what type of time complexity?
What is exponential time?
A simulation is run only 5 times and produces very different results each run. The programmer increases the number of trials to improve reliability. This change primarily reduces what issue?
What is variability (or random fluctuation)?
A variable is assigned the value of another variable, and later the second variable changes. The first variable does not change. This demonstrates what concept about assignment?
What is that assignment copies the value, not the variable (no automatic linkage)?
A nested conditional sets a result to true only when condition A is true and condition B is also true; in all other cases it sets the result to false. What single Boolean expression is equivalent to this logic?
What is "A AND B"?
A library contains a function that returns the length of a list and another that returns the maximum value. A programmer writes code that assumes both functions return the same data type. This error best describes what type of issue?
What is a type mismatch (or incorrect assumption about return types)?
Two algorithms solve the same problem. One runs in O(n log n), the other in O(n²). For very small inputs, the slower-growing algorithm may still perform worse. This is primarily due to what hidden factor?
What is constant factors (or implementation overhead)?
A simulation consistently produces results that are far from the expected outcome, even after thousands of trials. This suggests a problem with what aspect of the simulation?
What is bias (or an incorrect model)?
A programmer writes:
x ← x + 1
This statement cannot be interpreted as a mathematical equation. Instead, it represents what fundamental programming concept?
What is reassignment (updating a variable’s stored value)?
A program prints "B" only when a number is greater than 5, less than 10, and even. What is the complete set of integer values that produce "B"?
What is 6 and 8?
A programmer uses a library function without understanding that it modifies the original list instead of returning a new one. This results in unintended side effects. What is the underlying concept being misunderstood?
What is mutability (or side effects of procedures)?
An algorithm has two nested loops where the outer loop runs n times and the inner loop runs only when a condition depending on n/2 is met, executing at most n/2 times total. What is the overall time complexity?
What is O(n)?
A programmer designs a simulation where one outcome is accidentally given a higher probability than intended. Even with many trials, the results remain skewed. This demonstrates that increasing trials cannot fix what type of error?
What is systematic error (or bias)?
Two variables, a and b, are used in sequence: first a ← b, then b ← a. After execution, both variables contain the same value. This failed attempt was trying to accomplish what task?
What is swapping two variables?
A program checks whether x is positive or negative, and inside each case, it only prints output if y is also positive. In all other cases, nothing is printed. Under what conditions will the program produce no output?
What is when y ≤ 0 and x ≠ 0, or when x = 0 and y ≤ 0?
A library function is documented to return a value only when the input list is non-empty. A programmer fails to check this condition before calling the function. This type of error is best classified as what?
What is a failure to handle edge cases (or lack of input validation / precondition violation)?
A program processes a list by repeatedly removing the first element until the list is empty. Each removal requires shifting all remaining elements. What is the overall time complexity of this process?
What is O(n²)?
Two different simulations model the same situation. One uses 100 trials, the other uses 10,000 trials. The larger simulation is more likely to produce accurate results due to what statistical principle?
What is the law of large numbers?
A variable is used in an expression before it has been assigned any value. This leads to what type of error or issue in many programming environments?
What is undefined value (or runtime/initialization error)?
A program prints "B" only if x > 10 and y > 10, but not when their sum exceeds 25. What is the full condition describing when "B" is printed?
What is x > 10 AND y > 10 AND x + y ≤ 25?
A programmer writes their own procedure that internally calls multiple library functions, each with known time complexities. To determine the overall efficiency, the programmer must analyze what combined concept?
What is the composition of algorithms (or combining time complexities of function calls)?
An algorithm divides a problem in half each step and does a linear amount of work combining results at each level of recursion. What is the overall time complexity?
What is O(n log n)?
A simulation is repeated many times, and the results are averaged to estimate an outcome. This average is used as an approximation of what underlying concept?
What is the expected value (or long-run average)?
A programmer updates a variable inside a loop using its previous value (e.g., accumulating a total). This pattern is essential for tracking running results and is known as what?
What is an accumulator (or iterative updating of a variable)?