# Searching Algorithms in Java

Searching algorithms are used to find or check the position of an element or to retrieve an element from a dataset. Searching can be done in a sequential or non-sequential manner. Sequential search (Linear Search) and binary search are two common search methods used to find elements in a data structure. Sequential search starts at the top of the list and checks each item in the list. Binary Search is a search algorithm for determining the position of an element in a sorted array.

The following section contains various programs on searching algorithms, linear search, and binary search algorithms. Each sample program includes a program description, Java code, and program output. All examples have been compiled and tested on Windows and Linux systems.

Here is the listing of Java programming examples on Searching:

## 1. Searching Algorithms in Java

Program Description
KMP Pattern Searching Algorithm in Java Java Program to Implement Knuth Morris Pratt Algorithm
Bitap Algorithm in SPP Java Program to Implement Bitap Algorithm
Boyer Moore Algorithm in SPP Java Program to Implement Boyer Moore Algorithm
Interpolation Search Algorithm in Java Java Program to Implement Interpolation Search Algorithm
Ternary Search Algorithm in Java Java Program to Implement Ternary Search Algorithm
Searching using Self-Organizing List in Java Java Program to Perform Searching using Self-Organizing Lists
Searching based on Locality of Reference in Java Java Program to Perform Searching based on Locality of Reference
Find Min Element in an Array using Linear Search in Java Java Program to Find Minimum Element in an Array using Linear Search
Find kth Largest Element in Sequence in Java Java Program to Find kth Largest Element in a Sequence
Find Peak Element using Naive Method in Java Java Program to Find Peak Element of an Array using Naive Method
Fibonacci Search Algorithm in Java Java Program to Search Sorted Sequence using Divide and Conquer

## 2. Binary Search Algorithm in Java

Program Description
Uniform Binary Search in Java Java Program to Perform Uniform Binary Search
Binary Vs Sequential Search in Java Java Program to Compare Binary and Sequential Search
Find Max Element using Binary Search in Java Java Program to Find Maximum Element in an Array using Binary Search
Binary Search Algorithm in Java Java Program to Implement a Binary Search Algorithm for a Specific Search Sequence
Find Min Element using Binary Search in Java Java Program to Find Minimum Element in an Array using Binary Search
Find Peak Element in Java Java Program to Find Peak Element of an Array using Binary Search
Find Number Occurrences using Binary Search in Java Java Program to Count Number of Occurrences of a Given Number using Binary Search
Maximum Subarray Sum using Binary Search in Java Java Program to Find the Maximum Subarray Sum using Binary Search

## 3. Java Algorithms for Median and Selection

Program Description
Find Median using Binary Search in Java Java Program to Find the Median of Two Sorted Arrays using Binary Search
Find Second Smallest of n Elements in Java Java Program to Find Second Smallest of n Elements with Complexity Constraint
Find K Closest Median Elements in Java Java Program to Find K Closest Median Elements
Median of Two Sorted Arrays in Java Java Program to Find Median of Two Arrays of Different Sizes