Remove duplicated lines (#4258)

Co-authored-by: Ranjeet Kumar Jena <ranjeetjena06@gmai.com>
Co-authored-by: Andrii Siriak <siryaka@gmail.com>
This commit is contained in:
Ranjeet Kumar Jena 2023-07-25 16:06:00 +05:30 committed by GitHub
parent 3c80e262a7
commit ef4ef42ed3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,7 +3,7 @@ package com.thealgorithms.datastructures.trees;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.Queue; import java.util.Queue;
/** /*
* This entire class is used to build a Binary Tree data structure. There is the * This entire class is used to build a Binary Tree data structure. There is the
* Node Class and the Tree Class, both explained below. * Node Class and the Tree Class, both explained below.
*/ */
@ -164,14 +164,12 @@ public class BinaryTree {
if (successor.right != null) { if (successor.right != null) {
successor.right.parent = successor.parent; successor.right.parent = successor.parent;
successor.parent.left = successor.right; successor.parent.left = successor.right;
successor.right = temp.right;
successor.right.parent = successor;
} else { } else {
successor.parent.left = null; successor.parent.left = null;
}
successor.right = temp.right; successor.right = temp.right;
successor.right.parent = successor; successor.right.parent = successor;
} }
}
if (temp == root) { if (temp == root) {
successor.parent = null; successor.parent = null;
@ -304,7 +302,7 @@ public class BinaryTree {
*/ */
public void bfs(Node localRoot) { public void bfs(Node localRoot) {
// Create a queue for the order of the nodes // Create a queue for the order of the nodes
Queue<Node> queue = new LinkedList<Node>(); Queue<Node> queue = new LinkedList<>();
// If the give root is null, then we don't add to the queue // If the give root is null, then we don't add to the queue
// and won't do anything // and won't do anything