Sentinel Value

A sentinel value is a special value in the context of an algorithm which uses its presence as a condition of termination, typically in a loop or recursive algorithm.

Introduced in CS247. We also see this with Skip Lists in CS240.

But how are sentinel values actually implemented?

Are sentinel values even commonly used?

  • hmm i guess it depends, with C-style strings, array of characters are terminated by a null character (\0), which thus serves as a sentinel value, marking the end of the string.