# Balanced Tree - AVL Tree in Java » grokonez

AVL Tree in Java - AVL Tree Data Structure: It is a balanced binary search tree - the heights of given node's children trees don't differ more than 1 (with height of node = max of its children node + 1).

https://grokonez.com/java/balanced-tree-avl-tree-java

Balanced Tree – AVL Tree in Java

In this tutorial, we're gonna look at AVL Tree Data Structure. It is a balanced binary search tree - the heights of given node's children trees don't differ more than 1 (with height of node = max of its children node + 1).

## AVL Rotations

Four types of unbalanced situations: - Left-Left: doubly left heavy situation => make a right rotation. - Right-Right: doubly right heavy situation => make a left rotation. - Left-Right: => make a left and a right rotation. - Right-Left: => make a right and left rotation.

### Right Rotation

``````
Node rightRotation(Node node) { // input C
Node newParentNode = node.getLeftNode(); // newParentNode = B
Node mid = newParentNode.getRightNode(); // store B's right node 'mid' (B < mid < C)

newParentNode.setRightNode(node); // C now becomes right node of B
node.setLeftNode(mid); // 'mid' now becomes left node of C

node.setHeight(Math.max(height(node.getLeftNode()), height(node.getRightNode())) + 1);
newParentNode.setHeight(Math.max(height(newParentNode.getLeftNode()), height(newParentNode.getRightNode())) + 1);

return newParentNode; // return B as the parent of A and C
``````}
``````
To simplify the sample, we assume that C has no right node. In general, right node of C will not be changed.

### Left Rotation

More at:

https://grokonez.com/java/balanced-tree-avl-tree-java

Balanced Tree – AVL Tree in Java

## How to Install OpenJDK 11 on CentOS 8

What is OpenJDK? OpenJDk or Open Java Development Kit is a free, open-source framework of the Java Platform, Standard Edition (or Java SE).

## Going Beyond Java 8: Local Variable Type Inference (var) - DZone Java

In this article, we will talk about the most important new feature introduced with Java 10, officially called local variable type inference. An extremely important function in java. You will regret skipping this article.

## Java Online Training | Java Online Course | ITGuru

Our Java Online Training provide you to learn about Java programming and its different features with realty. Our Java Online Course includes live sessions, live projects

## Spring Boot and Java 16 Records

In this article, we will discuss Java 16's newest feature, Records. Then we will apply this knowledge and use it in conjunction with a Spring Boot application. An extremely important function in java. You will regret skipping this article.

## Best Java IDE 2020 | Most Popular Java IDE

Our Java Online Training provide you to learn about Java programming and its different features with realty. Our Java Online Course includes live sessions, live projects