Binary Search in Java
Binary search in java Home / 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 […]
Sorting a list in Python
SORTING A LIST IN PYTHON Home / problem You have a list of items in Python and you wish to sort them, e.g. put them in ascending order. If we assume we have a list of numbers, that would be from the lowest to the greatest (ascending), or vice versa (descending). SOLUTION Let’s assume we […]