diff --git a/src/main/java/com/thealgorithms/datastructures/trees/BSTIterative.java b/src/main/java/com/thealgorithms/datastructures/trees/BSTIterative.java index db3d0438f..97c266700 100644 --- a/src/main/java/com/thealgorithms/datastructures/trees/BSTIterative.java +++ b/src/main/java/com/thealgorithms/datastructures/trees/BSTIterative.java @@ -10,10 +10,10 @@ import com.thealgorithms.datastructures.trees.BinaryTree.Node; *

* An implementation of BST iteratively. Binary Search Tree is a binary tree * which satisfies three properties: left child is less than root node, right - * child is grater than root node, both left and right childs must themselves be + * child is grater than root node, both left and right child must themselves be * a BST. * - * @author [Lakhan Nad](https://github.com/Lakhan-Nad) + * @author [Lakhan Nad](git-Lakhan Nad) */ public class BSTIterative { diff --git a/src/main/java/com/thealgorithms/datastructures/trees/BSTRecursive.java b/src/main/java/com/thealgorithms/datastructures/trees/BSTRecursive.java index 34959556a..4e24f4bfb 100644 --- a/src/main/java/com/thealgorithms/datastructures/trees/BSTRecursive.java +++ b/src/main/java/com/thealgorithms/datastructures/trees/BSTRecursive.java @@ -17,7 +17,7 @@ import com.thealgorithms.datastructures.trees.BinaryTree.Node; * I have made public functions as methods and to actually implement recursive * approach I have used private methods * - * @author [Lakhan Nad](https://github.com/Lakhan-Nad) + * @author [Lakhan Nad](git-Lakhan Nad) */ public class BSTRecursive { diff --git a/src/main/java/com/thealgorithms/datastructures/trees/BSTRecursiveGeneric.java b/src/main/java/com/thealgorithms/datastructures/trees/BSTRecursiveGeneric.java index b70fcb280..5c1334ffa 100644 --- a/src/main/java/com/thealgorithms/datastructures/trees/BSTRecursiveGeneric.java +++ b/src/main/java/com/thealgorithms/datastructures/trees/BSTRecursiveGeneric.java @@ -9,10 +9,10 @@ import java.util.List; *

* A recursive implementation of generic type BST. * - * Reference: https://en.wikipedia.org/wiki/Binary_search_tree + * Reference: Wiki links for BST *

* - * @author [Madhur Panwar](https://github.com/mdrpanwar) + * @author [Madhur Panwar](git-Madhur Panwar) */ public class BSTRecursiveGeneric> { @@ -219,7 +219,7 @@ public class BSTRecursiveGeneric> { } /** - * Serach recursively if the given value is present in BST or not. + * Search recursively if the given value is present in BST or not. * * @param node the node under which to check * @param data the value to be checked diff --git a/src/main/java/com/thealgorithms/datastructures/trees/CeilInBinarySearchTree.java b/src/main/java/com/thealgorithms/datastructures/trees/CeilInBinarySearchTree.java index a6878c759..6e1454f68 100644 --- a/src/main/java/com/thealgorithms/datastructures/trees/CeilInBinarySearchTree.java +++ b/src/main/java/com/thealgorithms/datastructures/trees/CeilInBinarySearchTree.java @@ -39,7 +39,7 @@ import com.thealgorithms.datastructures.trees.BinaryTree.Node; * ii) If key is lesser than root value than ceil will be in right subtree so * call recursively on right subtree iii) if key is greater than current root, * then either a) the root is ceil b) ceil is in left subtree: call for left - * subtree. If left subtree returns a non null value then that will be ceil + * subtree. If left subtree returns a non-null value then that will be ceil * otherwise the root is ceil */ public class CeilInBinarySearchTree { diff --git a/src/main/java/com/thealgorithms/datastructures/trees/CheckIfBinaryTreeBalanced.java b/src/main/java/com/thealgorithms/datastructures/trees/CheckIfBinaryTreeBalanced.java index 9dd50245b..566536256 100644 --- a/src/main/java/com/thealgorithms/datastructures/trees/CheckIfBinaryTreeBalanced.java +++ b/src/main/java/com/thealgorithms/datastructures/trees/CheckIfBinaryTreeBalanced.java @@ -12,7 +12,7 @@ import java.util.Stack; * `isBalancedRecursive()` is implemented in a recursive fashion, and * `isBalancedIterative()` is implemented in an iterative fashion. * - * @author [Ian Cowan](https://github.com/iccowan) + * @author [Ian Cowan](Git-Ian Cowan) */ public class CheckIfBinaryTreeBalanced { /** diff --git a/src/main/java/com/thealgorithms/datastructures/trees/CheckTreeIsSymmetric.java b/src/main/java/com/thealgorithms/datastructures/trees/CheckTreeIsSymmetric.java index 0df93cefb..def455dde 100644 --- a/src/main/java/com/thealgorithms/datastructures/trees/CheckTreeIsSymmetric.java +++ b/src/main/java/com/thealgorithms/datastructures/trees/CheckTreeIsSymmetric.java @@ -39,16 +39,16 @@ public class CheckTreeIsSymmetric { return isSymmetric(root.left, root.right); } - private static boolean isSymmetric(Node leftSubtreeRoot, Node rightSubtreRoot) { - if (leftSubtreeRoot == null && rightSubtreRoot == null) { + private static boolean isSymmetric(Node leftSubtreeRoot, Node rightSubtreeRoot) { + if (leftSubtreeRoot == null && rightSubtreeRoot == null) { return true; } - if (isInvalidSubtree(leftSubtreeRoot, rightSubtreRoot)) { + if (isInvalidSubtree(leftSubtreeRoot, rightSubtreeRoot)) { return false; } - return isSymmetric(leftSubtreeRoot.right, rightSubtreRoot.left) && isSymmetric(leftSubtreeRoot.left, rightSubtreRoot.right); + return isSymmetric(leftSubtreeRoot.right, rightSubtreeRoot.left) && isSymmetric(leftSubtreeRoot.left, rightSubtreeRoot.right); } private static boolean isInvalidSubtree(Node leftSubtreeRoot, Node rightSubtreeRoot) { diff --git a/src/main/java/com/thealgorithms/datastructures/trees/GenericTree.java b/src/main/java/com/thealgorithms/datastructures/trees/GenericTree.java index 25347e2f8..d34846781 100644 --- a/src/main/java/com/thealgorithms/datastructures/trees/GenericTree.java +++ b/src/main/java/com/thealgorithms/datastructures/trees/GenericTree.java @@ -16,32 +16,32 @@ import java.util.Scanner; */ public class GenericTree { - private class Node { + private static class Node { int data; ArrayList child = new ArrayList<>(); } - private Node root; + private final Node root; public GenericTree() { // Constructor Scanner scn = new Scanner(System.in); root = create_treeG(null, 0, scn); } - private Node create_treeG(Node node, int childindx, Scanner scn) { + private Node create_treeG(Node node, int childIndex, Scanner scanner) { // display if (node == null) { System.out.println("Enter root's data"); } else { - System.out.println("Enter data of parent of index " + node.data + " " + childindx); + System.out.println("Enter data of parent of index " + node.data + " " + childIndex); } // input node = new Node(); - node.data = scn.nextInt(); + node.data = scanner.nextInt(); System.out.println("number of children"); - int number = scn.nextInt(); + int number = scanner.nextInt(); for (int i = 0; i < number; i++) { - Node child = create_treeG(node, i, scn); + Node child = create_treeG(node, i, scanner); node.child.add(child); } return node; diff --git a/src/main/java/com/thealgorithms/datastructures/trees/LCA.java b/src/main/java/com/thealgorithms/datastructures/trees/LCA.java index 26d3a844f..d45f0d4f4 100644 --- a/src/main/java/com/thealgorithms/datastructures/trees/LCA.java +++ b/src/main/java/com/thealgorithms/datastructures/trees/LCA.java @@ -5,7 +5,7 @@ import java.util.Scanner; public class LCA { - private static Scanner scanner = new Scanner(System.in); + private static final Scanner scanner = new Scanner(System.in); public static void main(String[] args) { // The adjacency list representation of a tree: @@ -91,7 +91,7 @@ public class LCA { return v1; } } -/** +/* * Input: * 10 * 0 1