2
yashdayma
23d

# Hello I am beginner in coding I have a doubt about sentinel search means can anyone give me a small example so that I can understand it properly

• 5
There isn't a "sentinel search" or "sentinel linear search" algorithm per se. That's mostly a poor translation courtesy of the bloat of unauthoritative plagiarized garbage floating around the internet.

A "sentinel node" is a value in a series or tree intentionally inserted at the end of the iterable series so that the result of the search will always return a value.

The word sentinel means a guard. The function of the sentinel value is to guard against null matches.

A linear search with a sentinel node will terminate with the query value. That value will then be returned at index n+1 if no other matches
are found:
find: "10"
source series: 1,2,3
n+1 series: 1,2,3,10

f(x,l) -> [...l,x].find(x);
• 3
@SortOfTested And the point of that is to safely omit range checks, which makes shit going faster.
• 0
Okay,
I will admit, i dont know what the talk is about, or i wont pretend i know shit about algorithms, but this sounds like null termination on string thing?
• 0
@DubbaThony That's a termination character, not a sentinel. The sentinel value is always the one you're looking for.
• 0
@Fast-Nop

Okay, if you remove abstraction wtf that means?

Edit: i mean like usage or something..

Like example

Edit2:
Okay, i googled it, and apparently yes, null termination character is sentiel value. But thats not algorithm or anything like that, just concept.
• 1
@DubbaThony It's not a sentinel. The big difference is that with a sentinel, you ONLY check for the value you're looking for when going through the data. With null termination, you look for a certain character or pattern and STILL have to do the null check.
• 1
@Fast-Nop

Okay, well, makes sense.
Google aint allways right and im too tired to filter that all. Just got curious, never heared of that thing and it sounded intriguing
• 0
@SortOfTested thank u for your help it really helped me