style: enable HideUtilityClassConstructor in checkstyle (#5147)

This commit is contained in:
Piotr Idzik
2024-05-08 08:58:29 +02:00
committed by GitHub
parent 030bb91d05
commit d3bb691f59
285 changed files with 895 additions and 339 deletions

View File

@@ -9,7 +9,9 @@ import com.thealgorithms.datastructures.trees.BinaryTree.Node;
* left half recursively to create left subtree 3. Use the right half
* recursively to create right subtree
*/
public class BSTFromSortedArray {
public final class BSTFromSortedArray {
private BSTFromSortedArray() {
}
public static Node createBST(int[] array) {
if (array == null || array.length == 0) {
return null;

View File

@@ -42,7 +42,9 @@ import com.thealgorithms.datastructures.trees.BinaryTree.Node;
* subtree. If left subtree returns a non-null value then that will be ceil
* otherwise the root is ceil
*/
public class CeilInBinarySearchTree {
public final class CeilInBinarySearchTree {
private CeilInBinarySearchTree() {
}
public static Node getCeil(Node root, int key) {
if (root == null) {

View File

@@ -8,7 +8,9 @@ package com.thealgorithms.datastructures.trees;
* where 'min' and 'max' values represent the child nodes (left, right).
* 2. The smallest possible node value is Integer.MIN_VALUE, the biggest - Integer.MAX_VALUE.
*/
public class CheckBinaryTreeIsValidBST {
public final class CheckBinaryTreeIsValidBST {
private CheckBinaryTreeIsValidBST() {
}
public static boolean isBST(BinaryTree.Node root) {
return isBSTUtil(root, Integer.MIN_VALUE, Integer.MAX_VALUE);
}

View File

@@ -14,7 +14,9 @@ import java.util.Stack;
*
* @author [Ian Cowan](<a href="https://github.com/iccowan">Git-Ian Cowan</a>)
*/
public class CheckIfBinaryTreeBalanced {
public final class CheckIfBinaryTreeBalanced {
private CheckIfBinaryTreeBalanced() {
}
/**
* Recursive is BT balanced implementation
*

View File

@@ -30,7 +30,9 @@ import com.thealgorithms.datastructures.trees.BinaryTree.Node;
*
* @author kumanoit on 10/10/22 IST 12:52 AM
*/
public class CheckTreeIsSymmetric {
public final class CheckTreeIsSymmetric {
private CheckTreeIsSymmetric() {
}
public static boolean isSymmetric(Node root) {
if (root == null) {

View File

@@ -17,7 +17,9 @@ import java.util.Map;
* Complexity: Time: O(n) hashmap reduced iteration to find index in inorder
* array Space: O(n) space taken by hashmap
*/
public class CreateBinaryTreeFromInorderPreorder {
public final class CreateBinaryTreeFromInorderPreorder {
private CreateBinaryTreeFromInorderPreorder() {
}
public static Node createTree(final Integer[] preorder, final Integer[] inorder) {
if (preorder == null || inorder == null) {
return null;

View File

@@ -25,7 +25,9 @@ import java.util.List;
*
* @author Albina Gimaletdinova on 21/02/2023
*/
public class InorderTraversal {
public final class InorderTraversal {
private InorderTraversal() {
}
public static List<Integer> recursiveInorder(BinaryTree.Node root) {
List<Integer> result = new ArrayList<>();
recursiveInorder(root, result);

View File

@@ -3,7 +3,9 @@ package com.thealgorithms.datastructures.trees;
import java.util.ArrayList;
import java.util.Scanner;
public class LCA {
public final class LCA {
private LCA() {
}
private static final Scanner SCANNER = new Scanner(System.in);

View File

@@ -5,7 +5,9 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
public class LevelOrderTraversal {
public final class LevelOrderTraversal {
private LevelOrderTraversal() {
}
public static List<List<Integer>> traverse(BinaryTree.Node root) {
if (root == null) {

View File

@@ -26,7 +26,9 @@ import java.util.List;
*
* @author Albina Gimaletdinova on 21/02/2023
*/
public class PostOrderTraversal {
public final class PostOrderTraversal {
private PostOrderTraversal() {
}
public static List<Integer> recursivePostOrder(BinaryTree.Node root) {
List<Integer> result = new ArrayList<>();
recursivePostOrder(root, result);

View File

@@ -25,7 +25,9 @@ import java.util.List;
*
* @author Albina Gimaletdinova on 17/02/2023
*/
public class PreOrderTraversal {
public final class PreOrderTraversal {
private PreOrderTraversal() {
}
public static List<Integer> recursivePreOrder(BinaryTree.Node root) {
List<Integer> result = new ArrayList<>();
recursivePreOrder(root, result);

View File

@@ -87,7 +87,9 @@ class Tree {
}
// Driver class to test above methods
public class PrintTopViewofTree {
public final class PrintTopViewofTree {
private PrintTopViewofTree() {
}
public static void main(String[] args) {
/* Create following Binary Tree

View File

@@ -32,7 +32,9 @@ import java.util.Deque;
*
* @author Albina Gimaletdinova on 13/01/2023
*/
public class SameTreesCheck {
public final class SameTreesCheck {
private SameTreesCheck() {
}
public static boolean check(BinaryTree.Node p, BinaryTree.Node q) {
if (p == null && q == null) {
return true;

View File

@@ -20,7 +20,9 @@ in a tree from top to bottom and left to right, so for a tree :
the sequence will be :
4 2 7 1 5 9 3 8 6 10
*/
public class VerticalOrderTraversal {
public final class VerticalOrderTraversal {
private VerticalOrderTraversal() {
}
/*Function that receives a root Node and prints the tree
in Vertical Order.*/

View File

@@ -34,7 +34,9 @@ import java.util.List;
*
* @author Albina Gimaletdinova on 11/01/2023
*/
public class ZigzagTraversal {
public final class ZigzagTraversal {
private ZigzagTraversal() {
}
public static List<List<Integer>> traverse(BinaryTree.Node root) {
if (root == null) {
return List.of();

View File

@@ -3,7 +3,9 @@ package com.thealgorithms.datastructures.trees;
import java.util.Scanner;
import java.util.concurrent.ThreadLocalRandom;
class Main {
final class NearestRightKey {
private NearestRightKey() {
}
public static void main(String[] args) {
NRKTree root = BuildTree();