mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-12-19 07:00:35 +08:00
Improved code readability and code quality (#4663)
* Fixed Small typos :-) * Update BufferedReader.java * Made the following changes : * Improved readability of files and removed gramatical errors. * Implemented data assigning instead of manually calling arr.ylength in several instances like FindMax, FindMaxRecursion etc. * Removed unwanted params from several files * Implemented Math methods in files math/FindMinRecursion.java and FindMaxRecursion.java * Update src/main/java/com/thealgorithms/maths/FindMinRecursion.java --------- Co-authored-by: Debasish Biswas <debasishbsws.dev@gmail.com>
This commit is contained in:
@@ -5,7 +5,7 @@ public final class FindMaxRecursion {
|
||||
private FindMaxRecursion() {
|
||||
}
|
||||
/**
|
||||
* Get max of array using divide and conquer algorithm
|
||||
* Get max of an array using divide and conquer algorithm
|
||||
*
|
||||
* @param array contains elements
|
||||
* @param low the index of the first element
|
||||
@@ -14,7 +14,7 @@ public final class FindMaxRecursion {
|
||||
*/
|
||||
public static int max(final int[] array, final int low, final int high) {
|
||||
if (array.length == 0) {
|
||||
throw new IllegalArgumentException("array must be non-empty.");
|
||||
throw new IllegalArgumentException("Array must be non-empty.");
|
||||
}
|
||||
if (low == high) {
|
||||
return array[low]; // or array[high]
|
||||
@@ -25,11 +25,11 @@ public final class FindMaxRecursion {
|
||||
int leftMax = max(array, low, mid); // get max in [low, mid]
|
||||
int rightMax = max(array, mid + 1, high); // get max in [mid+1, high]
|
||||
|
||||
return leftMax < rightMax ? rightMax : leftMax;
|
||||
return Math.max(leftMax, rightMax);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get max of array using recursion algorithm
|
||||
* Get max of an array using recursion algorithm
|
||||
*
|
||||
* @param array contains elements
|
||||
* @return max value of {@code array}
|
||||
|
||||
Reference in New Issue
Block a user