Binary Search in Java
Binary search in java problem You have an array of numbers that are sorted in ascending order and you wish to apply the binary search algorithm using Java. SOLUTION Let’s implement the algorithm: BinarySearch.java import java.util.Arrays; public class BinarySearch { public static void main(String[] args) { int[] numbers = new int[]{1,2,3,4,5,6,7,8,9,10}; //pre-sorted in Ascending order, […]
Bubble sort in Java
bubble sort in java problem You wish to sort a list of numbers from the smallest to the greatest or vice versa. In this post we will see one of the sorting algorithms called Bubble Sort. Let’s suppose we have a list of 10 numbers, and wish to sort them in an ascending order. SOLUTION […]