College Board Quiz

Question Answered Incorrectly

Correction

For this problem I answered [-3, -2, -1] which was the incorrect answer. The correct asnwer is [-1, 0, 1]. The reason why is the computer flips the sign of all the integers until they are all positive. For the answer I chose, all the negative numbers are negative so when the sign is flipped they all become positve so the procedure is able to work. [-1, 0, 1] does not work since there is both a negative numer and positive number so matter how may times you flip the signs one of the numbers will always be negative. Therefore, the procedure will not produce the intended result.

Notes

Learning Objective 1: For errors in an algorith or program: identify an error

-a logic error is a mistake in the algorithm or program that casues it to behave incorrectly or unexpectedly

-a syntax error is a mistake in the program where the rules of the programming language are not followed

-a run time error is a mistake in the program that occurs during the executiom of the program. Programming language define their own runtime errors

-A overflow error is an error that occurs when a computer attempts to handle a number that is outside of the defined range of values

Learning Objective 2: For errors in an algorithm or program: correct the error

-The following are effective ways to find and correct errors: tests cases, hand tracing, visualizations, debuggers, adding extra output statements

Learning Objective 3: Identify inputs and corresponding expected outputs or behaviors that can be used to check the correctness of an algorithm or program

-In the development process, testing uses defined inputs to ensure that an algorithm or program is producing the expected outcomes. Programmers use the results from testing to revise their algorithms or programs

-Defined inputs used to test a program should demonstrate the different expected outcomes that are at or just beyond the extremes of input data

-Program requirements are needed to identify appropriate defined inpputs for testing