Can anyone tell me what is sentinel while loop in C++? Please give me an example using sentinel while loop.
A "sentinel" in this context is a special value used to indicate the end of a sequence. The most common sentinel is \0 at the end of strings. A "sentinel while loop" would typically have the form: while (Get(input) != Sentinel) { Process(input); }
A sentinel loop is a short segment of adynamic ileus close to an intra-abdominal inflammatory process. When seen, it is usually identified on abdominal radiography. The sentinel loop sign may aid in localizing the source of inflammation.
A "sentinel" in this context is a special value used to indicate the end of a sequence. The most common sentinel is \0 at the end of strings. A "sentinel while loop" would typically have the form:
while (Get(input) != Sentinel) {
Process(input);
}
A sentinel is a special value, e.g. boolean value, extremely big or small. It is used to determine when to stop the loop.
A good example is in the implementation of merge sort, e.g. read page 4 of http://www.cs.princeton.edu/courses/archive/spr07/cos226/lectures/04MergeQuick.pdf.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With