Insertion Sort in Java

Insertion Sort in Java


Insertion sort is simple sorting algorithm that sorts the complete array by picking one element at a time and shifting it at its right place.

Lets understand above line in more details with the help of an example. Given a array of integers, Sort it using Insertion sort.  

Lets understand what is the input and the expected output.

Linear Search Algorithm in Java

Linear Search Algorithm in Java OR
Sequential Search Algorithm in Java

Linear search is a searching algorithm which sequentially searches element in an array.

In this algorithm, elements of array is scanned one by one and check if it is matching with element to search and if found return true else return false.

Lets understand the problem statement graphically and it will be more clear,  



How Binary search Algorithm works in Java

How Binary search Algorithm works in Java.

Binary search is a technique for searching an element from sorted array.

Let's understand Binary Search Algorithm with the help of an example, 
You will be given a sorted array and an element, find whether element is present in array or not.
 

Binary Search in Java

Binary Search in Java.

Binary search is a technique for searching an element from sorted array.

Let's understand Binary Search with the help of an example,
You will be given a sorted array and an element, find whether element is present in array or not.
Lets understand the problem statement graphically and it will be more clear,  
 

Find element in a sorted array

Binary Search in Sorted Array OR
Given a sorted array, Search a given element in array.


Searching an element in a sorted array.
You will be given a sorted array and an element, you need to find whether element is present in array or not.

Lets understand the problem statement graphically and it will be more clear,