egonSchiele / grokking_algorithms

Code for the book Grokking Algorithms (https://amzn.to/29rVyHf)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Binary Search in Java is not working properly without sorting it first.

opened this issue · comments

public class BinarySearch {
public static void main(String[] args) {
int[] myList = {87, 21, 45, 93};

   //add this line  Arrays.sort(myList);
    System.out.println(binarySearch(myList, 93));

I might be wrong, I am just a newbie