Binary Search in Java

Binary search is an optimized algorithm to perform searching operation. It follows Divide and Conquer approach for searching. Pre-condition of Binary search : To perform Binary search the array should be sorted in ascending or descending order. Logic of Binary Search Let us consider array is sorted in ascending order. Now we compare the element … Read more

Selection Sorting in Java

In selection sorting each element is compared with all the following elements of the array. If the element is greater than any following element then swapping is done. After the first cycle we obtain the smallest element at the starting. Now in the second cycle, second element is compared with all following elements to obtain … Read more

Bubble Sorting in Java

Bubble sorting and Linear sorting are the easiest methods of sorting. Also they are the least optimized sorting algorithms. First we are going to look at bubble sorting in java. In Bubble sort each element is compared with its next element, if the element is greater than the next element then they are swapped. This … Read more