True or false: An algorithm must eventually stop after a finite sequence of steps.
2 Algorithms and Solution Design Online Quiz Questions
Use this free practice quiz with 20 questions to review 2 Algorithms and Solution Design, test your knowledge, and prepare for your next test or exam.
Which flowchart symbol should represent the question “Is purchaseAmount at least 100?”
- A
A rectangle
- B
A diamond
- C
A parallelogram
- D
An oval or rounded rectangle
What computational-thinking technique divides a complex task into smaller subproblems?
Complete the specification: The information supplied to an algorithm is its , and the result it produces is its .
An algorithm repeatedly displays the values 1 through 5 by executing a loop. Which basic control structure is being used?
- A
Iteration
- B
Selection
- C
Sequence
- D
Validation
True or false: In the discount algorithm, the loop that rejects negative purchase amounts is an example of input validation rather than normal result processing.
- A
True
- B
False
Which test inputs would directly test the discount threshold or the nonnegative-input validation rule? Select all correct choices.
- A
99.99
- B
100
- C
-5
- D
80
Using the stated discount rule, what final price results from a purchase amount of 150 dollars? Enter the value in dollars.
Complete the pseudocode keyword: purchaseAmount >= 100 THEN begins the conditional that chooses whether to apply the discount.
A dry run uses purchaseAmount = 120. What output format is required after applying the discount and rounding the monetary result as specified?
- A
$108
- B
$108.0
- C
$108.00
- D
$108.000
Which properties are explicitly expected of a well-designed algorithm? Select all correct choices.
- A
Correct for every valid input
- B
Unambiguous
- C
Visually colorful
- D
Testable
Design a language-independent algorithm for the store discount problem. It must accept a nonnegative purchase amount, apply a 10% discount only when the amount is at least 100, reject negative input through re-entry, and display the final price rounded to two decimal places. Describe the steps in pseudocode or precise ordered prose.
Which statement best describes an assumption in an algorithmic problem specification?
- A
A result produced after the algorithm finishes
- B
An accepted condition that the problem does not otherwise specify
- C
A symbol used only for output in a flowchart
- D
A test value chosen only because it is invalid
True or false: In a flowchart, a diamond represents a decision or condition.
- A
True
- B
False
Which basic control structure should you use when an algorithm must repeat a group of instructions while or until a condition is satisfied?
A program must reject negative purchase amounts and ask for another value before calculating a price. Which step is input validation?
- A
Calculate the final price for a valid purchase amount.
- B
Check whether the purchase amount satisfies the nonnegative constraint.
- C
Apply the discount to every purchase amount.
- D
Round the final price to two decimal places.
Using the discount rule described in the material, what is the final price for a valid purchase amount of 150 dollars? Enter the numeric value to the nearest cent.
An algorithm gives a discount when a purchase amount is at least 100. Which test set most directly checks the boundary and the behavior on both sides of it?
- A
80, 150, and 200
- B
0, 50, and 75
- C
99.99, 100, and 100.01
- D
-5, -1, and 0
A flowchart must show the step that displays the calculated final price. Which symbol should represent that input or output action?
- A
Parallelogram
- B
Rectangle
- C
Diamond
- D
Oval or rounded rectangle
Which specification best describes a general solution for the store discount problem?
- A
Apply the discount only to purchase amounts greater than 100.
- B
Calculate a result only when the purchase amount is exactly 100.
- C
Reject every purchase amount below 100 as invalid.
- D
For every nonnegative amount, apply the discount at or above 100 and otherwise leave the amount unchanged.