How Does a Sentinel Value Work in an Algorithm?

  • Thread starter Thread starter jackson6612
  • Start date Start date
  • Tags Tags
    Algorithm Value
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
3 replies · 3K views
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.
 
Physics 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