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

## Search given key in BST | Recursive & Iterative Solution

Given a BST, write an efficient function to search a given key in it. The algorithm should return the parent node of the key and print if the key is left or right node of the parent node. If the key is not present in the BST, the algorithm should be able to determine that.

## Find shortest route in a device to construct the given string

Given a device having left, right, top and bottom buttons and a OK button to enter a text from a virtual keypad having alphabets from A-Y arranged in a 5×5 grid as shown below. We need to find the shortest route in device to construct the given string if we start from the top-left position …

## Count number of paths in a matrix with given cost to reach destination cell

Given a M x N matrix where each cell have non-negative cost associated with it, count number of paths to reach last cell (M-1, N-1) of the matrix from its first cell (0, 0) such that path has given cost. We can only move one unit right or one unit down from any cell. i.e. …

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

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