# Binary Search using Recursion in Java

Write a program to implement a Binary search using recursion in java. In this tutorial, I am going to discuss binary search algorithm and it’s implementation using recursion in Java.

In my previous tutorial, i have explained how to implement binary search in java using iterative approach.

Difference between recursion and iteration

Binary Search using Recursion in Java

## How Does Binary Search Algorithm Works?

i) Binary search algorithm works only for sorted array.

ii) In binary search, we start by comparing middle element of the array with the search value. If search value is found, then the index of the middle element is returned. If the search value is less than or greater than the middle element, than the search continues in the lower or upper half of the array.

iii) The time complexity of binary search is O(n).

Subscribe Our Tutorials

a) Best case time complexity of binary search is O(1) (when element in found at mid index)

b) Worst case time complexity of binary search is  O(logn)

Find first and last position of a number in a sorted array

In this example, i have explained how binary search works.

Binary Search algorithm explained with example

## Binary Search using Recursion in Java

I have explained what is binary search? And how it works. Let’s write a java code to implement binary search using recursion.

## Binary Search using Recursion Video Tutorial

In this video tutorial, I have explained step by step how we can implement binary search using recursion in java.