How Does a Sentinel Value Work in an Algorithm?

  • Thread starter Thread starter jackson6612
  • Start date Start date
  • Tags Tags
    Algorithm Value
Click For Summary

Discussion Overview

The discussion revolves around the concept of sentinel values in algorithms, specifically in the context of processing student data. Participants explore how a sentinel value, such as a specific student ID, can signal the end of data input without the program needing to know the total amount of data in advance.

Discussion Character

  • Technical explanation
  • Conceptual clarification

Main Points Raised

  • One participant expresses confusion about how a sentinel value functions in an algorithm that processes student data, specifically questioning how the program transitions to checking for the sentinel value after processing the last student's data.
  • Another participant explains that the sentinel value allows the program to operate without prior knowledge of the amount of data, indicating that the program stops processing when it encounters the sentinel ID (0000000).
  • A further contribution clarifies that the input data file must be structured so that the last entry contains the sentinel value, which is not considered real data but serves to indicate the end of valid input.
  • A participant expresses gratitude for the concise explanations provided, indicating that the responses met their needs for clarity.

Areas of Agreement / Disagreement

Participants appear to agree on the function and necessity of sentinel values in the algorithm, with no significant disagreement noted in the responses provided.

Contextual Notes

The discussion assumes familiarity with programming concepts and does not address potential variations in how sentinel values might be implemented in different programming languages or contexts.

jackson6612
Messages
334
Reaction score
1
Hi

Please have a look on this scanned page:
http://img257.imageshack.us/img257/8175/chap11page191.jpg

I humbly request you to be precise and to the point in your replies. I need you help and need to understand this as soon as possible. Thank a lot.

Suppose there were 100 students and once it has processed the percentage of the last student (100th) it writes output data and then goes back to first step "Read Input Data" as the 'arrow line' suggests. Well, there is any more Input Data so the program will keep on looking for the Input Data. How is it suppose to lead to the step "Is Roll no. = 0000000" - a sentinel value? I don't understand it.

Please help me.
 
Technology news on Phys.org
Using a sentinel or trailer value, the program doing the processing doesn't need to know how much data there is.

Basically the program reads a student ID. If the ID is 0000000, the program stops. If the ID is not 0000000, it reads in data about that student, does some calculations, and then goes back to read another student ID.
 
In order for the algorithm to work properly, the input data file must be constructed so that the last line or data set contains 0000000 in the position that normally contains the roll number. This last line is not intended to be used as "real data." It exists only as a "sentinel" which signals that there is no more "real data."
 
I understand it now. Thank you, both of you, Mark, JT. These are the answers I call concise and to the point. Or, as you say in English, don't give me what I ask for, give me what I need.

Best wishes
Jackson
 

Similar threads

Replies
9
Views
4K
  • · Replies 3 ·
Replies
3
Views
5K
Replies
6
Views
5K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 14 ·
Replies
14
Views
2K
Replies
29
Views
6K
  • · Replies 9 ·
Replies
9
Views
3K
Replies
20
Views
5K