# Tag: Searching

## 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 O(log(n)) time. Get great deals at Amazon

## 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.

## Least Cost Path in Weighted Digraph using BFS

Consider a directed graph where weight of its edges can be one of x, 2x or 3x (x is a given integer), compute the least cost path from source to destination efficiently.

## Find Frequency of each element in a sorted array containing duplicates

Given a sorted array containing duplicates, efficiently find frequency of each element in it without traversing the whole array.

## Find Minimum and Maximum element in an array by doing minimum comparisons

Given an array of integers, find minimum and maximum element present in it by doing minimum comparisons using using divide and conquer technique.

## Implementation of KMP Algorithm in C, C++ and Java

In this post, we will implement KMP Algorithm in C, C++ and Java programming language.

## Implement strstr function in Java

Write an efficient algorithm to implement strstr function in Java which returns the index of first occurrence of a string in another string.

## Introduction to Pattern Matching

Given a text, find all occurrences of a given pattern in it.

## Find Minimum and Maximum element in an array using minimum comparisons

Given an array of integers, find out minimum and maximum element present using minimum comparisons.

## 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 log(n) 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.