# Tag: Binary Search

## Find Missing Term in a Sequence in log(n) time

Given a sequence of numbers such that the difference between the consecutive terms is constant, find missing term in it in log(n) time.

## Division of Two Numbers using Binary Search Algorithm

In this post, we will discuss division of two numbers (integer or decimal) using Binary Search (Divide and Conquer) Algorithm.

## Find Floor and Ceil of a number in a sorted array (Recursive solution)

Given a sorted array of integers, find floor and ceil of a given number in it. The floor and ceiling map the given number to the largest previous or the smallest following integer, respectively.

## Ternary Search vs Binary search

In this article, we will implement Ternary Search algorithm and compare its performance with Binary Search.

## Find peak element in an array

Given an array, find peak element in it. A peak element is an element that is greater than its neighbors.

## Find number of 1’s in a sorted binary array

Given a sorted binary array, efficiently find the number of 1’s in it.

## Search in a nearly sorted array in O(logn) time

Given a nearly sorted array such that each of the N elements may be misplaced by no more than one position from the correct sorted order, efficiently search a given element in it. Report if the element is not present in the input array.   An element at index i in correct sorted order can …

## Find Floor and Ceil of a number in a sorted array

Given a sorted array of integers, find floor and ceil of a given number in it. The floor and ceil map the given number to the largest previous or the smallest following integer, respectively.

## Find smallest missing element from a sorted array

Given a sorted array of distinct non-negative integers, find smallest missing element in it.

## Count occurrences of a number in a sorted array with duplicates

Given a sorted array of integers containing duplicates, count occurrences of a number provided. If the element is not found in the array, report that as well.

## Find first or last occurrence of a given number in a sorted array

Given a sorted array of integers, find index of first or last occurrence of a given number. If the element is not found in the array, report that as well.

## Search an element in a circular sorted array

Given a circular sorted array of integers, search an element in it. Assume there are no duplicates in the array and the rotation is in anti-clockwise direction.