Skip to content

java convenction changes #4259

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
* <p>
* 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](<a href="https://github.com/Lakhan-Nad">git-Lakhan Nad</a>)
*/

public class BSTIterative {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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](<a href="https://github.com/Lakhan-Nad">git-Lakhan Nad</a>)
*/
public class BSTRecursive {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
* <p>
* A recursive implementation of generic type BST.
*
* Reference: https://en.wikipedia.org/wiki/Binary_search_tree
* Reference: <a href="https://en.wikipedia.org/wiki/Binary_search_tree">Wiki links for BST</a>
* </p>
*
* @author [Madhur Panwar](https://github.com/mdrpanwar)
* @author [Madhur Panwar](<a href="https://github.com/mdrpanwar">git-Madhur Panwar</a>)
*/
public class BSTRecursiveGeneric<T extends Comparable<T>> {

Expand Down Expand Up @@ -219,7 +219,7 @@ private void inOrderSort(Node<T> node, List<T> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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](<a href="https://github.com/iccowan">Git-Ian Cowan</a>)
*/
public class CheckIfBinaryTreeBalanced {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,24 @@
*/
public class GenericTree {

private class Node {
private static class Node {

int data;
ArrayList<Node> 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 + " " + childIndx);
}
// input
node = new Node();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -91,7 +91,7 @@ private static int getLCA(int v1, int v2, int[] depth, int[] parent) {
return v1;
}
}
/**
/*
* Input:
* 10
* 0 1
Expand Down