mirror of
https://github.com/TheAlgorithms/Java.git
synced 2026-03-13 08:40:43 +08:00
style: enable LocalVariableName in CheckStyle (#5191)
* style: enable LocalVariableName in checkstyle * Removed minor bug * Resolved Method Name Bug * Changed names according to suggestions
This commit is contained in:
@@ -112,10 +112,10 @@ public class AVLSimple {
|
||||
|
||||
private Node rightRotate(Node c) {
|
||||
Node b = c.left;
|
||||
Node T3 = b.right;
|
||||
Node t3 = b.right;
|
||||
|
||||
b.right = c;
|
||||
c.left = T3;
|
||||
c.left = t3;
|
||||
c.height = Math.max(height(c.left), height(c.right)) + 1;
|
||||
b.height = Math.max(height(b.left), height(b.right)) + 1;
|
||||
return b;
|
||||
@@ -123,10 +123,10 @@ public class AVLSimple {
|
||||
|
||||
private Node leftRotate(Node c) {
|
||||
Node b = c.right;
|
||||
Node T3 = b.left;
|
||||
Node t3 = b.left;
|
||||
|
||||
b.left = c;
|
||||
c.right = T3;
|
||||
c.right = t3;
|
||||
c.height = Math.max(height(c.left), height(c.right)) + 1;
|
||||
b.height = Math.max(height(b.left), height(b.right)) + 1;
|
||||
return b;
|
||||
|
||||
@@ -60,13 +60,13 @@ class Tree {
|
||||
HashSet<Integer> set = new HashSet<>();
|
||||
|
||||
// Create a queue and add root to it
|
||||
Queue<QItem> Q = new LinkedList<QItem>();
|
||||
Q.add(new QItem(root, 0)); // Horizontal distance of root is 0
|
||||
Queue<QItem> queue = new LinkedList<QItem>();
|
||||
queue.add(new QItem(root, 0)); // Horizontal distance of root is 0
|
||||
|
||||
// Standard BFS or level order traversal loop
|
||||
while (!Q.isEmpty()) {
|
||||
while (!queue.isEmpty()) {
|
||||
// Remove the front item and get its details
|
||||
QItem qi = Q.remove();
|
||||
QItem qi = queue.remove();
|
||||
int hd = qi.hd;
|
||||
TreeNode n = qi.node;
|
||||
|
||||
@@ -79,10 +79,10 @@ class Tree {
|
||||
|
||||
// Enqueue left and right children of current node
|
||||
if (n.left != null) {
|
||||
Q.add(new QItem(n.left, hd - 1));
|
||||
queue.add(new QItem(n.left, hd - 1));
|
||||
}
|
||||
if (n.right != null) {
|
||||
Q.add(new QItem(n.right, hd + 1));
|
||||
queue.add(new QItem(n.right, hd + 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,9 +10,9 @@ public class SegmentTree {
|
||||
public SegmentTree(int n, int[] arr) {
|
||||
this.n = n;
|
||||
int x = (int) (Math.ceil(Math.log(n) / Math.log(2)));
|
||||
int seg_size = 2 * (int) Math.pow(2, x) - 1;
|
||||
int segSize = 2 * (int) Math.pow(2, x) - 1;
|
||||
|
||||
this.seg_t = new int[seg_size];
|
||||
this.seg_t = new int[segSize];
|
||||
this.arr = arr;
|
||||
this.n = n;
|
||||
constructTree(arr, 0, n - 1, 0);
|
||||
|
||||
Reference in New Issue
Block a user