Difficulty: Easy
Correct Answer: Sentinel values
Explanation:
Introduction / Context:
When writing loops that read input or process sequences of data, it is often necessary to know when to stop. Instead of always knowing the exact number of items in advance, programmers can use a special value to mark the end. This special value is known by a specific term in algorithm design and programming practice. The question checks whether you know that term.
Given Data / Assumptions:
Concept / Approach:
The widely used term for a value that signals the end of a sequence or terminates a loop is sentinel value. A sentinel value is placed at the end of an array or used as a termination input so that the loop can stop when it reads that value. It is a classic pattern in algorithms and is frequently used in examples where input continues until the user enters a specific code such as minus one.
Step-by-Step Solution:
Step 1: Remember that in a sentinel controlled loop, the loop continues reading input until it encounters a particular value.
Step 2: Recall example exercises where users type values until they enter a terminator such as minus one, which is not treated as regular data.
Step 3: Recognise that the special value in such scenarios is called a sentinel value in algorithm terminology.
Step 4: Compare the given options and locate the one that uses the term sentinel values.
Step 5: Select sentinel values as the correct answer, since this is the textbook term for the concept.
Verification / Alternative check:
You can quickly check your memory by recalling the phrase sentinel controlled repetition, which appears in many programming textbooks. The controlling value is the sentinel that signals the end of repetition. This confirms that sentinel is the correct technical term that the question is looking for.
Why Other Options Are Wrong:
Option A: Stop values is an informal phrase and not the standard term used in algorithm discussions.
Option C: End values is also informal and does not match the widely recognised term sentinel values.
Option D: Finish values is not a term used in mainstream programming or algorithm literature.
Common Pitfalls:
A common pitfall is to use generic words like terminator or end without learning the formal term. While those words describe the idea, exam questions usually want the term sentinel value. Another mistake is to confuse sentinel values with flags or boolean variables, which are different techniques for controlling program flow.
Final Answer:
Values used to signal the end of input or terminate a loop are called Sentinel values.
Discussion & Comments