> For the complete documentation index, see [llms.txt](https://soumyajit4419.gitbook.io/ds-algo/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://soumyajit4419.gitbook.io/ds-algo/binary-search/template-ii.md).

# Template II

It is used to search for an element or condition which requires ***accessing the current index** and its **immediate right neighbor's index*** in the array.

**Key Attributes:**

* An advanced way to implement Binary Search.
* Search Condition needs to access element's immediate right neighbor
* Use element's right neighbor to determine if condition is met and decide whether to go left or right

**Distinguishing Syntax:**

* Initial Condition: `left = 0, right = length-1`
* Termination: `left < right`
* Searching Left: `right = mid`
* Searching Right: `left = mid+1`
