---
title: "Sentinel in sequential search"
subject: "Data Structure and Algorithm"
chapter: 8
key: "semester_4/data_structure_and_algorithm:sentinel-sequential-search-importance"
source: https://www.bctengineer.com/q/semester_4/data_structure_and_algorithm/sentinel-sequential-search-importance
site: BCT Engineering
---

# Sentinel in sequential search

Data Structure and Algorithm · Chapter 8: Searching

- Asked in: 2070 Magh, 2 marks
- Video: [Sentinel search algorithm | Searching algorithm | Sequential searching](https://www.youtube.com/watch?v=PPDBcQOPZbc) — For CS
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_4/data_structure_and_algorithm/sentinel-sequential-search-importance
- Whole chapter: https://www.bctengineer.com/md/semester_4/data_structure_and_algorithm/chapter-8

## Question

What is the importance of using Sentinel during sequential searching?

## Short answer

A sentinel copy stored at a[n] removes the bound check from the loop, reducing comparisons from two to one per step. This nearly halves work and guarantees termination; if i==n after loop, key not found.

## Answer

A sentinel is a copy of the search key placed just after the last element of the array (a[n] = key). It guarantees that the loop will find the key, so the test "i < n" can be removed from the loop condition.

Importance:
- The loop makes **one comparison per step** (a[i] != key) instead of two (i < n and a[i] != key), which almost halves the work for large arrays.
- The loop always stops, so there is no risk of running past the array end.
- After the loop, if i == n the key was found only at the sentinel, so it is not in the list.

The array needs one spare location.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. What is a sentinel?
   A. A copy of the key placed after the last element (a[n] = key)
   B. The first element
   C. A pointer to NULL
   D. A sorted index
   Answer: A. It guarantees the search stops. (Key point: What)

2. What does a sentinel remove?
   A. The a[i] != key test
   B. The i < n test, leaving one comparison per step
   C. The loop
   D. The need for the key
   Answer: B. Only a[i] != key is needed. (Key point: Benefit)

3. After the loop with a sentinel, i == n means?
   A. Key found at n
   B. Key is not in the list
   C. Loop error
   D. Array full
   Answer: B. The key was found only at the sentinel. (Key point: Not found)

## Related in Data Structure and Algorithm

- [Sequential search and sentinel](https://www.bctengineer.com/question.md?key=semester_4%2Fdata_structure_and_algorithm%3Asequential-search-sentinel) — Data Structure and Algorithm, chapter 8
- [Sequential vs binary search](https://www.bctengineer.com/question.md?key=semester_4%2Fdata_structure_and_algorithm%3Asequential-vs-binary-search) — Data Structure and Algorithm, chapter 8

## Related in other subjects

- [Searching: BFS vs DFS comparison](https://www.bctengineer.com/question.md?key=semester_6%2Fartificial_intelligence%3Ablind-search-dfs-bfs-compare) — Artificial Intelligence, chapter 3, asked 5×
- [Components of indexing and searching](https://www.bctengineer.com/question.md?key=semester_8%2Fbig_data_technologies%3Aindexing-searching-components) — Big Data Technologies, chapter 5, asked 2×
