diff --git a/src/main/java/com/thealgorithms/datastructures/trees/BSTIterative.java b/src/main/java/com/thealgorithms/datastructures/trees/BSTIterative.java
index db3d0438f4fe..97c2667002b6 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 @@
*
* 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 34959556a0c3..4e24f4bfb32a 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 @@
* 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 b70fcb280ac3..5c1334ffa0e8 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 @@
*
* 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 @@ private void inOrderSort(Node node, List sortedList) {
}
/**
- * 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 a6878c75981d..6e1454f6859b 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 @@
* 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 9dd50245b88e..566536256558 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 @@
* `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 0df93cefb9e3..def455dde051 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 static boolean isSymmetric(Node root) {
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 25347e2f8b1c..d348467815c7 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 @@
*/
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 26d3a844f7b9..d45f0d4f4301 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 @@
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 @@ private static int getLCA(int v1, int v2, int[] depth, int[] parent) {
return v1;
}
}
-/**
+/*
* Input:
* 10
* 0 1