egonSchiele / grokking_algorithms

Code for the book Grokking Algorithms (https://amzn.to/29rVyHf)
Other
11.73k stars 3.8k forks source link

Update to more semantic code in Java #297

Open rafhael-s-p opened 1 month ago

rafhael-s-p commented 1 month ago

Methods guessEqualsItem, guessGreaterThanItem, and guessLessThanItem from java examples of chapter 1 binary search check the contrary condition of their names, this might sound weird.

Example of suggestion:

Instead of public static boolean guessGreaterThanItem(int guess, int item) { if (guess < item) { return false; } return true; }

Do public static boolean guessGreaterThanItem(int guess, int item) { if (guess > item) { return true; } return false; }

If you grant me permission I will open the Merge Request for the improvment.