Bubble Sort in Java

In this tutorial you will learn about bubble sort in Java. In bubble sort algorithm each element is compared with adjacent element and are swapped if not in correct order. It is one of the simplest but worst sorting algorithm. It is suitable for sorting small list of numbers. As bubbles come up on surface in water, in the same way the lighter or smaller elements come forward and heavier or bigger elements goes back. Below image shows how bubble

Read more

Difference between Array and ArrayList in Java

Here you will learn about difference between array and arraylist in java. Both array and arraylist are most important and frequently used data structure in java. Below I have discussed about various differences between them.   Difference between Array and ArrayList in Java Property Array ArrayList Size Array is fixed in size. Once declared, its size can’t be changed. ArrayList size can be changed after declaration. For example when we add or remove element in arraylist, its size increases or

Read more

Binary Search in Java

In this tutorial you will learn about binary search in Java. Binary search is a searching algorithm that uses divide and conquer technique. The array on which searching is to be done must be sorted in ascending order. The target element is compared with middle element. If it is less than middle element then left half is discarded and if it is greater than middle element then right half is discarded. Now a new middle element is calculated in the remaining

Read more

Linear Search in Java

Here you will learn about linear search in Java. It is one of the simplest and basic searching algorithm which is also known as sequential search. The targeted element is compared with each element of array until it is found. Its best and worst case time complexity is O (1) and O (n) respectively. Also Read: Binary Search in Java Below program shows that how to implement this algorithm in Java. Program for Linear Search in Java

  Output Enter

Read more
1 2