In the beginning, you will most likely try to use a brute force method to solve search problems; this is because it is the easiest and most rudimentary way to find a target. However brute force has a time cost; The Big O notation of brute force is usually and unacceptably equal to or greater than bigO(n²).
Generally, when implementing a search problem you are better off to search from a sorted list. You can think about looking at a random list of Apartments from a google search. Now think about looking at a google list of Apartments sorted by distance from you. Generally sorted lists are much more useful. Binary Search will not work for an unsorted list because it uses a sort of educated guess; you cannot make educated guesses on random and arbitrary lists.
In the binary search, array elements must be in ascending order. If you have an unsorted array, you can sort the array using Arrays.sort(arr) method.
What is OpenJDK? OpenJDk or Open Java Development Kit is a free, open-source framework of the Java Platform, Standard Edition (or Java SE).
Searching Algorithms in Java. A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.
Divide and conquer algorithm. A binary search is a searching algorithm for finding an item from a sorted list of items. It works by repeatedly dividing in half the portion of the list that could contain the item until you’ve narrowed down the possible locations to just one. As compared to linear, binary search is much faster with Time Complexity of O(logN) whereas the linear search algorithm works in O(N) time complexity. The implementation of binary search can be done iteratively or recursively.