{"id":83522,"date":"2021-08-19T09:00:00","date_gmt":"2021-08-19T03:30:00","guid":{"rendered":"https:\/\/techvidvan.com\/tutorials\/?p=83522"},"modified":"2021-08-19T09:00:00","modified_gmt":"2021-08-19T03:30:00","slug":"avl-tree-in-data-structure","status":"publish","type":"post","link":"https:\/\/techvidvan.com\/tutorials\/avl-tree-in-data-structure\/","title":{"rendered":"AVL Tree in Data Structure"},"content":{"rendered":"<p>An AVL tree is a height-balanced binary search tree. The AVL tree is named after its inventors:<strong> A<\/strong>delson-<strong>V<\/strong>elsky and <strong>L<\/strong>andis. In an AVL tree, the heights of the two-child subtrees can differ by utmost 1. AVL trees are based on a balancing factor. An AVL tree must have a balancing factor of either -1, 0 or 1. If the balancing factor is something else, we need to rebalance the AVL tree until the balancing factor is either 0, -1 or 1.<\/p>\n<h3>Balancing Factor:<\/h3>\n<p>The difference between the height of the left subtree and the height of the right subtree is known as the balancing factor. In an AVL tree, each node maintains extra information about the balancing factor. In an AVL tree, the balancing factor must be 0, -1 or 1. The balancing factor helps to maintain the self-balancing property of the AVL tree.<\/p>\n<p>Thus, Balancing factor = (height of left subtree) &#8211; (height of right subtree)<br \/>\nOr, Balancing factor = (height of right subtree) &#8211; (height of left subtree)<\/p>\n<p>Thus, for a tree to be an AVL tree:<\/p>\n<ul>\n<li>It must be a binary search tree.<\/li>\n<li>Its balancing factor must be -1, 0 or 1.<\/li>\n<\/ul>\n<p>The following diagram depicts a height-balanced AVL tree.<\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/TV-AVL-tree-in-DS-normal-images01.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-84126\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/TV-AVL-tree-in-DS-normal-images01.jpg\" alt=\"AVL tree in DS\" width=\"518\" height=\"471\" \/><\/a><\/p>\n<h3>Why AVL Trees:<\/h3>\n<p>For a binary search tree, the time taken to for execution is O(h) and in AVL trees, this height is balanced. In a simple binary search tree, the height could reach up to O(n) whenever the search tree is skewed. But, in the case of AVL trees, skewness can never exist and so the complexity is always the O(log n).<\/p>\n<h3>Operations on AVL trees:<\/h3>\n<p>We can perform the following operations on an AVL tree:<br \/>\n1. AVL rotations<br \/>\n2. Searching<br \/>\n3. Insertion<br \/>\n4. Deletion<\/p>\n<h3>AVL Rotations:<\/h3>\n<p>An AVL tree performs four kinds of rotations to balance itself. These four rotations are:<\/p>\n<h4>a. AVL Left Rotation:<\/h4>\n<p>If a node in a tree becomes unbalanced due to the nodes of the right subtree, then we left-rotate the parent node to balance the tree. Left rotation is performed on a right-skewed binary search tree.<\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/TV-AVL-tree-in-DS-normal-images02.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-84127\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/TV-AVL-tree-in-DS-normal-images02.jpg\" alt=\"AVL left Rotation\" width=\"612\" height=\"317\" \/><\/a><\/p>\n<h4>b. AVL Right Rotation:<\/h4>\n<p>If a tree is not height-balanced due to the left subtree, we rotate it in the rightward direction to balance it. Right rotation is performed from left-skewed binary search trees.<\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/TV-AVL-tree-in-DS-normal-images03.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-84128\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/TV-AVL-tree-in-DS-normal-images03.jpg\" alt=\"AVL Right Rotation\" width=\"612\" height=\"317\" \/><\/a><\/p>\n<h4>c. AVL Left-right Rotation:<\/h4>\n<p>It comprises two rotations to balance the subtree- a left rotation and a right rotation. Consider the following example of a skewed binary search tree:<\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/TV-AVL-tree-in-DS-normal-images04.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-84129\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/TV-AVL-tree-in-DS-normal-images04.jpg\" alt=\"AVL Left-Right Rotation\" width=\"922\" height=\"389\" \/><\/a><\/p>\n<p>Here, R is unbalanced with a balancing factor of 2. Thus, we need to balance it. To balance it, we will first perform left rotation on the subtree of R. This will make it completely left-skewed. Then, we will perform the right rotation on this tree and get the balanced tree.<\/p>\n<h4>d. AVL Right-left Rotation:<\/h4>\n<p>It comprises a right rotation and a left rotation to balance the height of the tree.<\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/TV-AVL-tree-in-DS-normal-images05.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-84130\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/TV-AVL-tree-in-DS-normal-images05.jpg\" alt=\"AVL Right-Left Rotation\" width=\"922\" height=\"389\" \/><\/a><\/p>\n<p>Here, P is unbalanced. To balance it, we first need to right rotate the tree such that it becomes completely right-skewed. Then, we will perform left rotation on it to balance the tree.<\/p>\n<h3>Insertion in AVL Tree:<\/h3>\n<p>Insertion in an AVL tree requires that nodes must be added to the AVL tree such that the balancing factor remains 0, 1 or -1. If the balancing factor is something else, we need to balance the node by performing rotations.<\/p>\n<p>If we need to insert a leaf node in an AVL tree, its balancing factor is always 0. So, we don\u2019t need to rebalance it. If we are inserting an internal node, we need to take care of the balancing factor.<\/p>\n<p>For example, consider the following AVL tree and make sure that it is height-balanced.<\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/TV-AVL-tree-in-DS-normal-images06.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-84131\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/TV-AVL-tree-in-DS-normal-images06.jpg\" alt=\"Insertion in AVL Tree\" width=\"518\" height=\"471\" \/><\/a><\/p>\n<p>Suppose we want to insert 42 in this tree. 42&gt;20, therefore, it will be in the right subtree. The next node is 50 and 50&gt;42, therefore, 42 will be in the left subtree of 50. Again, 32&lt;42, so 42 will be on the right subtree of 32. The next node we encounter is 46 and 46&gt;42, thus, the final place of 42 will be on the left of 46 as shown:<\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/TV-AVL-tree-in-DS-normal-images07.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-84132\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/TV-AVL-tree-in-DS-normal-images07.jpg\" alt=\"AVL Insertion\" width=\"518\" height=\"565\" \/><\/a><\/p>\n<p>However, on inserting 42, the balancing factor of 32 becomes -2 and the balancing factor of 50 becomes 2. Thus, the insertion of a new node has disrupted the balancing factor of the tree. This imbalance is due to 3 nodes- 32, 46 and 42.<\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/TV-AVL-tree-in-DS-normal-images08.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-84133\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/TV-AVL-tree-in-DS-normal-images08.jpg\" alt=\"Insertion in AVL\" width=\"518\" height=\"565\" \/><\/a><\/p>\n<p>If we are able to balance them, we will balance the whole tree. To balance these 3 nodes, we will first perform a right rotation as shown:<\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/TV-AVL-tree-in-DS-normal-images09.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-84134\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/TV-AVL-tree-in-DS-normal-images09.jpg\" alt=\"Insertion in AVL Tree\" width=\"518\" height=\"565\" \/><\/a><\/p>\n<p>Then, we will perform a left rotation.<\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/TV-AVL-tree-in-DS-normal-images10.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-84135\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/TV-AVL-tree-in-DS-normal-images10.jpg\" alt=\"Left Rotation in AVL\" width=\"518\" height=\"471\" \/><\/a><\/p>\n<p>Finally, after performing these two rotations, we will get the balanced tree.<\/p>\n<h3>Deletion in AVL Trees:<\/h3>\n<p>The deletion works in a similar manner. First, we need to find the node to be deleted. Then, we delete the node and if the tree loses balance on removing the need, then we need to rebalance it. We know that deletion of any node in any binary search tree is handled in three different cases:<\/p>\n<p>1. The node is a leaf node<br \/>\n2. The node is an internal node having one child<br \/>\n3. The node is an internal node having two child nodes<\/p>\n<p>Consider the following tree:<\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/TV-AVL-tree-in-DS-normal-images11.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-84136\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/TV-AVL-tree-in-DS-normal-images11.jpg\" alt=\"Deletion in AVL tree\" width=\"518\" height=\"471\" \/><\/a><\/p>\n<p>Suppose we wish to delete 50.<\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/TV-AVL-tree-in-DS-normal-images12.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-84137\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/TV-AVL-tree-in-DS-normal-images12.jpg\" alt=\"Delete node in AVL\" width=\"518\" height=\"471\" \/><\/a><\/p>\n<p>On deleting 50, 60 will be replaced by 50 and 50 will be deleted as shown:<\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/TV-AVL-tree-in-DS-normal-images13-1.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-84138\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/TV-AVL-tree-in-DS-normal-images13-1.jpg\" alt=\"Deleting node in AVL\" width=\"443\" height=\"447\" \/><\/a><\/p>\n<p>Now, the tree has become unbalanced due to the nodes: 60, 42 and 32.<\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/TV-AVL-tree-in-DS-normal-images13-2.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-84139\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/TV-AVL-tree-in-DS-normal-images13-2.jpg\" alt=\"Unbalanced AVL\" width=\"443\" height=\"447\" \/><\/a><\/p>\n<p>This is a left-skewed tree so will perform right rotation to balance it. Thus, after performing the right rotation, the tree will become as follows:<\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/TV-AVL-tree-in-DS-normal-images14.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-84140\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/TV-AVL-tree-in-DS-normal-images14.jpg\" alt=\"Deletion in AVL\" width=\"482\" height=\"314\" \/><\/a><\/p>\n<p>This is a height-balanced AVL tree.<\/p>\n<h3>AVL Tree Implementation in C:<\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#include &lt;stdio.h&gt;\n#include &lt;stdlib.h&gt;\n\nstruct Node {\n    int key;\n    struct Node *left_child;\n    struct Node *right_child;\n    int height;\n};\n\nint Max(int a, int b);\n\nint height(struct Node *N) {\n    if (N == NULL)\n        return 0;\n    return N-&gt;height;\n}\n\nint Max(int num1, int num2) {\n    return (num1 &gt; num2) ? num1 : num2;\n}\n\nstruct Node *new_node(int key) {\n    struct Node *node = (struct Node *) malloc(sizeof(struct Node));\n    node-&gt;key = key;\n    node-&gt;left_child = NULL;\n    node-&gt;right_child = NULL;\n    node-&gt;height = 1;\n    return (node);\n}\n\nstruct Node *right_rotate(struct Node *b) {\n    struct Node *a = b-&gt;left_child;\n    struct Node *t = a-&gt;right_rotate;\n    a-&gt;right_child = b;\n    b-&gt;left_child = t;\n    b-&gt;height = Max(height(b-&gt;left_child), height(b-&gt;right_child)) + 1;\n    a-&gt;height = Max(height(a-&gt;left_child), height(a-&gt;right_child)) + 1;\n    return a;\n}\n\nstruct Node *left_rotate(struct Node *a) {\n    struct Node *b = a-&gt;right_child;\n    struct Node *t = b-&gt;left_child;\n    b-&gt;left_child = a;\n    a-&gt;right_child = t;\n    a-&gt;height = Max(height(a-&gt;left_child), height(a-&gt;right_child)) + 1;\n    b-&gt;height = Max(height(b-&gt;left_child), height(b-&gt;right_child)) + 1;\n    return b;\n}\n\nint get_balancing_factor(struct Node *N) {\n    if (N == NULL)\n        return 0;\n    return height(N-&gt;left_child) - height(N-&gt;right_child);\n}\n\nstruct Node *insert_node(struct Node *node, int key) {\n    if (node == NULL)\n        return (new_node(key));\n    if (key &lt; node-&gt;key)\n        node-&gt;left_child = insert_node(node-&gt;left_child, key);\n    else if (key &gt; node-&gt;key)\n        node-&gt;right_child = insert_node(node-&gt;right_child, key);\n    else\n        return node;\n    node-&gt;height = 1 + Max(height(node-&gt;left_child), height(node-&gt;right_child));\n    int balance = get_balancing_factor(node);\n    if (balance &gt; 1 &amp;&amp; key &lt; node-&gt;left_child-&gt;key)\n        return right_rotate(node);\n    if (balance &lt; -1 &amp;&amp; key &gt; node-&gt;right_rotate-&gt;key)\n        return left_rotate(node);\n    if (balance &gt; 1 &amp;&amp; key &gt; node-&gt;left_child-&gt;key) {\n        node-&gt;left_child = left_rotate(node-&gt;left_child);\n        return right_rotate(node);\n    }\n    if (balance &lt; -1 &amp;&amp; key &lt; node-&gt;right_child-&gt;key) {\n        node-&gt;right_child = right_rotate(node-&gt;right_child);\n        return left_rotate(node);\n    }\n    return node;\n}\n\nstruct Node *min_value(struct Node *node) {\n    struct Node *current = node;\n    while (current-&gt;left_child != NULL)\n        current = current-&gt;left_child;\n    return current;\n}\n\nstruct Node *delete_node(struct Node *root, int key) {\n    if (root == NULL)\n        return root;\n\n    if (key &lt; root-&gt;key)\n        root-&gt;left_child = delete_node(root-&gt;left_child, key);\n    else if (key &gt; root-&gt;key)\n        root-&gt;right_child = delete_node(root-&gt;right_child, key);\n    else {\n        if ((root-&gt;left_child == NULL) || (root-&gt;right_child == NULL)) {\n            struct Node *temp = root-&gt;left_child ? root-&gt;left_child : root-&gt;right_child;\n            if (temp == NULL) {\n                temp = root;\n                root = NULL;\n            }\n            else\n                *root = *temp;\n            free(temp);\n        } \n        else {\n            struct Node *temp = min_value(root-&gt;right_child);\n            root-&gt;key = temp-&gt;key;\n            root-&gt;right_child = delete_node(root-&gt;right_child, temp-&gt;key);\n        }\n    }\n    if (root == NULL)\n        return root;\n    root-&gt;height = 1 + Max(height(root-&gt;left_child), height(root-&gt;right_child));\n    int balance = get_balancing_factor(root);\n    if (balance &gt; 1 &amp;&amp; get_balancing_factor(root-&gt;left_child) &gt;= 0)\n        return right_rotate(root);\n    if (balance &gt; 1 &amp;&amp; get_balancing_factor(root-&gt;left_child) &lt; 0) {\n        root-&gt;left_child = left_rotate(root-&gt;left_child);\n        return right_rotate(root);\n    }\n    if (balance &lt; -1 &amp;&amp; get_balancing_factor(root-&gt;right_child) &lt;= 0)\n        return left_rotate(root);\n    if (balance &lt; -1 &amp;&amp; get_balancing_factor(root-&gt;right_child) &gt; 0) {\n        root-&gt;right_child = right_rotate(root-&gt;right_child);\n        return left_rotate(root);\n    }\n    return root;\n}\n\nvoid Display_preOrder(struct Node *root) {\n    if (root != NULL) {\n        printf(\"%d \", root-&gt;key);\n        Display_preOrder(root-&gt;left_child);\n        Display_preOrder(root-&gt;right_child);\n    }\n}\n\nint main() {\n    struct Node *root = NULL;\n    root = insert_node(root, 20);\n    root = insert_node(root, 10);\n    root = insert_node(root, 60);\n    root = insert_node(root, 8);\n    root = insert_node(root, 15);\n    root = insert_node(root, 42);\n    root = insert_node(root, 50);\n    root = insert_node(root, 32);\n    Display_preOrder(root);\n    root = delete_node(root, 50);\n    printf(\"\\nAfter deletion: \");\n    Display_preOrder(root);\n    return 0;\n}\n<\/pre>\n<h3>Implementation of AVL Tree in C++:<\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#include &lt;bits\/stdc++.h&gt;\n\nstruct Node {\n    int key;\n    struct Node *left_child;\n    struct Node *right_child;\n    int height;\n};\n\nint Max(int a, int b);\n\nint height(struct Node *N) {\n    if (N == NULL)\n        return 0;\n    return N-&gt;height;\n}\n\nint Max(int num1, int num2) {\n    return (num1 &gt; num2) ? num1 : num2;\n}\n\nstruct Node *new_node(int key) {\n    struct Node *node = (struct Node *) malloc(sizeof(struct Node));\n    node-&gt;key = key;\n    node-&gt;left_child = NULL;\n    node-&gt;right_child = NULL;\n    node-&gt;height = 1;\n    return (node);\n}\n\nstruct Node *right_rotate(struct Node *b) {\n    struct Node *a = b-&gt;left_child;\n    struct Node *t = a-&gt;right_rotate;\n    a-&gt;right_child = b;\n    b-&gt;left_child = t;\n    b-&gt;height = Max(height(b-&gt;left_child), height(b-&gt;right_child)) + 1;\n    a-&gt;height = Max(height(a-&gt;left_child), height(a-&gt;right_child)) + 1;\n    return a;\n}\n\nstruct Node *left_rotate(struct Node *a) {\n    struct Node *b = a-&gt;right_child;\n    struct Node *t = b-&gt;left_child;\n    b-&gt;left_child = a;\n    a-&gt;right_child = t;\n    a-&gt;height = Max(height(a-&gt;left_child), height(a-&gt;right_child)) + 1;\n    b-&gt;height = Max(height(b-&gt;left_child), height(b-&gt;right_child)) + 1;\n    return b;\n}\n\nint get_balancing_factor(struct Node *N) {\n    if (N == NULL)\n        return 0;\n    return height(N-&gt;left_child) - height(N-&gt;right_child);\n}\n\nstruct Node *insert_node(struct Node *node, int key) {\n    if (node == NULL)\n        return (new_node(key));\n    if (key &lt; node-&gt;key)\n        node-&gt;left_child = insert_node(node-&gt;left_child, key);\n    else if (key &gt; node-&gt;key)\n        node-&gt;right_child = insert_node(node-&gt;right_child, key);\n    else\n        return node;\n    node-&gt;height = 1 + Max(height(node-&gt;left_child), height(node-&gt;right_child));\n    int balance = get_balancing_factor(node);\n    if (balance &gt; 1 &amp;&amp; key &lt; node-&gt;left_child-&gt;key)\n        return right_rotate(node);\n    if (balance &lt; -1 &amp;&amp; key &gt; node-&gt;right_rotate-&gt;key)\n        return left_rotate(node);\n    if (balance &gt; 1 &amp;&amp; key &gt; node-&gt;left_child-&gt;key) {\n        node-&gt;left_child = left_rotate(node-&gt;left_child);\n        return right_rotate(node);\n    }\n    if (balance &lt; -1 &amp;&amp; key &lt; node-&gt;right_child-&gt;key) {\n        node-&gt;right_child = right_rotate(node-&gt;right_child);\n        return left_rotate(node);\n    }\n    return node;\n}\n\nstruct Node *min_value(struct Node *node) {\n    struct Node *current = node;\n    while (current-&gt;left_child != NULL)\n        current = current-&gt;left_child;\n    return current;\n}\n\nstruct Node *delete_node(struct Node *root, int key) {\n    if (root == NULL)\n        return root;\n\n    if (key &lt; root-&gt;key)\n        root-&gt;left_child = delete_node(root-&gt;left_child, key);\n    else if (key &gt; root-&gt;key)\n        root-&gt;right_child = delete_node(root-&gt;right_child, key);\n    else {\n        if ((root-&gt;left_child == NULL) || (root-&gt;right_child == NULL)) {\n            struct Node *temp = root-&gt;left_child ? root-&gt;left_child : root-&gt;right_child;\n            if (temp == NULL) {\n                temp = root;\n                root = NULL;\n            }\n            else\n                *root = *temp;\n            free(temp);\n        } \n        else {\n            struct Node *temp = min_value(root-&gt;right_child);\n            root-&gt;key = temp-&gt;key;\n            root-&gt;right_child = delete_node(root-&gt;right_child, temp-&gt;key);\n        }\n    }\n    if (root == NULL)\n        return root;\n    root-&gt;height = 1 + Max(height(root-&gt;left_child), height(root-&gt;right_child));\n    int balance = get_balancing_factor(root);\n    if (balance &gt; 1 &amp;&amp; get_balancing_factor(root-&gt;left_child) &gt;= 0)\n        return right_rotate(root);\n    if (balance &gt; 1 &amp;&amp; get_balancing_factor(root-&gt;left_child) &lt; 0) {\n        root-&gt;left_child = left_rotate(root-&gt;left_child);\n        return right_rotate(root);\n    }\n    if (balance &lt; -1 &amp;&amp; get_balancing_factor(root-&gt;right_child) &lt;= 0)\n        return left_rotate(root);\n    if (balance &lt; -1 &amp;&amp; get_balancing_factor(root-&gt;right_child) &gt; 0) {\n        root-&gt;right_child = right_rotate(root-&gt;right_child);\n        return left_rotate(root);\n    }\n    return root;\n}\n\nvoid Display_preOrder(struct Node *root) {\n    if (root != NULL) {\n        cout&lt;&lt; root-&gt;key;\n        Display_preOrder(root-&gt;left_child);\n        Display_preOrder(root-&gt;right_child);\n    }\n}\n\nint main() {\n    struct Node *root = NULL;\n    root = insert_node(root, 20);\n    root = insert_node(root, 10);\n    root = insert_node(root, 60);\n    root = insert_node(root, 8);\n    root = insert_node(root, 15);\n    root = insert_node(root, 42);\n    root = insert_node(root, 50);\n    root = insert_node(root, 32);\n    Display_preOrder(root);\n    root = delete_node(root, 50);\n    cout&lt;&lt; \"\\nAfter deletion: \";\n    Display_preOrder(root);\n    return 0;\n}\n<\/pre>\n<h3>AVL Tree Implementation in Java:<\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">class Node {\n  int value, height;\n  Node left_child, right_child;\n  Node(int data) {\n    value = data;\n    height = 1;\n  }\n}\n\nclass AVLTree {\n  Node root;\n\n  int height(Node N) {\n    if (N == null)\n      return 0;\n    return N.height;\n  }\n\n  int Max(int num1, int num2) {\n    return (num1 &gt; num2) ? num1 : num2;\n  }\n\n  Node right_rotate(Node b) {\n    Node a = b.left_child;\n    Node t = a.right_child;\n    a.right_child = b;\n    b.left_child = t;\n    b.height = Max(height(y.left_child), height(y.right_child)) + 1;\n    a.height = Max(height(x.left_child), height(x.right_child)) + 1;\n    return a;\n  }\n\n  Node left_rotate(Node a) {\n    Node b = a.right_child;\n    Node t = y.left_child;\n    b.left_child = a;\n    a.right_child = t;\n    a.height = Max(height(a.left_child), height(a.right_child)) + 1;\n    b.height = Max(height(b.left_child), height(b.right_child)) + 1;\n    return b;\n  }\n\n  int get_balance_factor(Node N) {\n    if (N == null)\n      return 0;\n    return height(N.left_child) - height(N.right_child);\n  }\n\n  Node insert_node(Node node, int value) {\n    if (node == null)\n      return (new Node(value));\n    if (value &lt; node.value)\n      node.left_child = insert_node(node.left_child, value);\n    else if (value &gt; node.value)\n      node.right_child = insert_node(node.right_child, value);\n    else\n      return node;\n    node.height = 1 + Max(height(node.left_child), height(node.right_child));\n    int balance = get_balance_factor(node);\n    if (balance &gt; 1) {\n      if (value &lt; node.left_child.value) {\n        return right_rotate(node);\n      } \n      else if (value &gt; node.left_child.value) {\n        node.left_child = left_rotate(node.left_child);\n        return right_rotate(node);\n      }\n    }\n    if (balance &lt; -1) {\n      if (value &gt; node.right_child.value) {\n        return left_rotate(node);\n      } \n      else if (value &lt; node.right_child.value) {\n        node.right_child = right_rotate(node.right_child);\n        return left_rotate(node);\n      }\n    }\n    return node;\n  }\n\n  Node min_value(Node node) {\n    Node current = node;\n    while (current.left_child != null)\n      current = current.left_child;\n    return current;\n  }\n\n  Node delete_node(Node root, int value) {\n    if (root == null)\n      return root;\n    if (value &lt; root.value)\n      root.left_child = delete_node(root.left_child, value);\n    else if (value &gt; root.value)\n      root.right_child = delete_node(root.right_child, value);\n    else {\n      if ((root.left_child == null) || (root.right_child == null)) {\n        Node temp = null;\n        if (temp == root.left_child)\n          temp = root.right_child;\n        else\n          temp = root.left_child;\n        if (temp == null) {\n          temp = root;\n          root = null;\n        } \n        else\n          root = temp;\n      } \n      else {\n        Node temp = min_value(root.right_child);\n        root.value = temp.value;\n        root.right_childt = delete_node(root.right_child, temp.value);\n      }\n    }\n    if (root == null)\n      return root;\n    root.height = Max(height(root.left_child), height(root.right_child)) + 1;\n    int balance = get_balance_factor(root);\n    if (balance &gt; 1) {\n      if (get_balance_factor(root.left_child) &gt;= 0) {\n        return right_rotate(root);\n      } else {\n        root.left_child = left_rotate(root.left_child);\n        return right_rotate(root);\n      }\n    }\n    if (balance &lt; -1) {\n      if (get_balance_factor(root.right_child) &lt;= 0) {\n        return left_rotate(root);\n      } else {\n        root.right_child = right_rotate(root.right_child);\n        return left_rotate(root);\n      }\n    }\n    return root;\n  }\n\n  void Display_preOrder(Node node) {\n    if (node != null) {\n      System.out.print(node.value + \" \");\n      Display_preOrder(node.left_child);\n      Display_preOrder(node.right_child);\n    }\n  }\n\n  private void Display_Tree(Node currPtr, String indent, boolean last) {\n    if (currPtr != null) {\n      System.out.print(indent);\n      if (last) {\n        System.out.print(\"R----\");\n        indent += \"   \";\n      } else {\n        System.out.print(\"L----\");\n        indent += \"|  \";\n      }\n      System.out.println(currPtr.value);\n      Display_Tree(currPtr.left_child, indent, false);\n      Display_Tree(currPtr.right_child, indent, true);\n    }\n  }\n\n  public static void main(String[] args) {\n    AVLTree tree = new AVLTree();\n    tree.root = tree.insert_node(tree.root, 20);\n    tree.root = tree.insert_node(tree.root, 10);\n    tree.root = tree.insert_node(tree.root, 50);\n    tree.root = tree.insert_node(tree.root, 8);\n    tree.root = tree.insert_node(tree.root, 15);\n    tree.root = tree.insert_node(tree.root, 60);\n    tree.root = tree.insert_node(tree.root, 42);\n    tree.root = tree.insert_node(tree.root, 32);\n   \n    \n    tree.Display_Tree(tree.root, \"\", true);\n    tree.root = tree.delete_node(tree.root, 50);\n    System.out.println(\"After Deletion: \");\n    tree.Display_Tree(tree.root, \"\", true);\n  }\n}\n<\/pre>\n<h3>Implementation of AVL Tree in Python:<\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">import sys\nclass Tree_node(object):\n    def __init__(self, key):\n        self.key = key\n        self.left_child = None\n        self.right_child = None\n        self.height = 1\n\nclass AVL_Tree(object):\n    def insert_node(self, root, key):\n        if not root:\n            return Tree_node(key)\n        elif key &lt; root.key:\n            root.left_child = self.insert_node(root.left_child, key)\n        else:\n            root.right_child = self.insert_node(root.right_child, key)\n        root.height = 1 + max(self.getHeight(root.left_child), self.getHeight(root.right_child))\n        balanceFactor = self.get_balancing_factor(root)\n        if balanceFactor &gt; 1:\n            if key &lt; root.left_child.key:\n                return self.right_rotate(root)\n            else:\n                root.left_child = self.left_rotate(root.left_child)\n                return self.right_rotate(root)\n\n        if balanceFactor &lt; -1:\n            if key &gt; root.right_child.key:\n                return self.left_rotate(root)\n            else:\n                root.right_child = self.right_rotate(root.right_child)\n                return self.left_rotate(root)\n        return root\n\n    def delete_node(self, root, key):\n        if not root:\n            return root\n        elif key &lt; root.key:\n            root.left_child = self.delete_node(root.left_child, key)\n        elif key &gt; root.key:\n            root.right_child = self.delete_node(root.right_child, key)\n        else:\n            if root.left_child is None:\n                temp = root.right_child\n                root = None\n                return temp\n            elif root.right_child is None:\n                temp = root.left_child\n                root = None\n                return temp\n            temp = self.min_value(root.right_child)\n            root.key = temp.key\n            root.right_child = self.delete_node(root.right_child, temp.key)\n        if root is None:\n            return root\n\n        root.height = 1 + Max(self.getHeight(root.left_child), self.getHeight(root.right_child))\n        balanceFactor = self.get_balancing_factor(root)\n\n        if balanceFactor &gt; 1:\n            if self.get_balancing_factor(root.left_child) &gt;= 0:\n                return self.right_rotate(root)\n            else:\n                root.left_child = self.left_rotate(root.left_child)\n                return self.right_rotate(root)\n        if balanceFactor &lt; -1:\n            if self.get_balancing_factor(root.right_child) &lt;= 0:\n                return self.left_rotate(root)\n            else:\n                root.right_child = self.right_rotate(root.right_child)\n                return self.left_rotate(root)\n        return root\n\n    def left_rotate(self, z):\n        y = z.right_child\n        T2 = y.left_rotate\n        y.left_child = z\n        z.right_child = T2\n        z.height = 1 + max(self.getHeight(z.left_child), self.getHeight(z.right_child))\n        y.height = 1 + max(self.getHeight(y.left_child),  self.getHeight(y.right_child))\n        return y\n\n    def right_rotate(self, z):\n        y = z.left\n        T3 = y.right\n        y.right = z\n        z.left = T3\n        z.height = 1 + max(self.getHeight(z.left_child),  self.getHeight(z.right_child))\n        y.height = 1 + max(self.getHeight(y.left_child), self.getHeight(y.right_child))\n        return y\n        \n    def getHeight(self, root):\n        if not root:\n            return 0\n        return root.height\n\n    def get_balancing_factor(self, root):\n        if not root:\n            return 0\n        return self.getHeight(root.left_child) - self.getHeight(root.right_child)\n        \n    def min_value(self, root):\n        if root is None or root.left_child is None:\n            return root\n        return self.min_value(root.left_child)\n\n    def Display_preOrder(self, root):\n        if not root:\n            return\n        print(\"{0} \".format(root.key), end=\"\")\n        self.Display_preOrder(root.left_child)\n        self.Display_preOrder(root.right_child)\n\n    def Display_Tree(self, currPtr, indent, last):\n        if currPtr != None:\n            sys.stdout.write(indent)\n            if last:\n                sys.stdout.write(\"R----\")\n                indent += \"     \"\n            else:\n                sys.stdout.write(\"L----\")\n                indent += \"|    \"\n            print(currPtr.key)\n            self.Display_Tree(currPtr.left_child, indent, False)\n            self.Display_Tree(currPtr.right_child, indent, True)\n\nmyTree = AVL_Tree()\nroot = None\nnums = [20, 10, 50, 8, 15, 42, 60, 32]\nfor num in nums:\n    root = myTree.insert_node(root, num)\nmyTree.Display_Tree(root, \"\", True)\nkey = 50\nroot = myTree.delete_node(root, key)\nprint(\"After Deletion: \")\nmyTree.Display_Tree(root, \"\", True)\n<\/pre>\n<h3>Complexity Analysis of AVL Tree:<\/h3>\n<table>\n<tbody>\n<tr>\n<td><b>Scenario\/Operation\u00a0<\/b><\/td>\n<td><b>Insertion\u00a0<\/b><\/td>\n<td><b>Deletion\u00a0<\/b><\/td>\n<td><b>Search\u00a0<\/b><\/td>\n<\/tr>\n<tr>\n<td><b>Average case<\/b><\/td>\n<td><span style=\"font-weight: 400\">O(log n)<\/span><\/td>\n<td><span style=\"font-weight: 400\">O(log n)<\/span><\/td>\n<td><span style=\"font-weight: 400\">O(log n)<\/span><\/td>\n<\/tr>\n<tr>\n<td><b>Best case<\/b><\/td>\n<td><span style=\"font-weight: 400\">O(log n)<\/span><\/td>\n<td><span style=\"font-weight: 400\">O(log n)<\/span><\/td>\n<td><span style=\"font-weight: 400\">O(log n)<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>The space complexity of all the operations in an AVL tree is O(n), where n is the number of nodes in the AVL tree.<\/p>\n<h3>Applications of AVL Trees:<\/h3>\n<ul>\n<li>Used for performing search operations when the dataset is very large<\/li>\n<li>Used to index large records in database management systems<\/li>\n<\/ul>\n<h3>Comparison with Red-black Trees:<\/h3>\n<p>If we compare AVL trees and red-black trees to a simple binary search tree, then both of them are more efficient than a BST. however, if we compare an AVL tree to a red-black tree, an AVL tree is better in terms of its performance and efficiency. AVL trees are more balanced as compared to red-black trees. But, if there are a lot of insertion and deletion operations, then we prefer red-black trees because AVL trees require a lot of rotations to balance in case of insertion and deletion.<\/p>\n<h3>Conclusion:<\/h3>\n<p>In this article, we have studied AVL trees, their need and importance, search, insert and delete operations on AVL trees, their implementation in C, C++, Java, Python and applications of AVL trees. From here, we can conclude that AVL trees are one of the most important parts of data structures and they improve the time complexity of trees and have many important applications.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>An AVL tree is a height-balanced binary search tree. The AVL tree is named after its inventors: Adelson-Velsky and Landis. In an AVL tree, the heights of the two-child subtrees can differ by utmost&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":84125,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3555],"tags":[4071,4072,4073,4074,4075,4076,4077],"class_list":["post-83522","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-data-structure","tag-avl-tree","tag-avl-tree-in-data-structure","tag-complexity-analysis-of-avl-tree","tag-deletion-in-avl-tree","tag-implementation-of-avl-tree","tag-insertion-in-avl","tag-rotation-in-avl"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>AVL Tree in Data Structure - TechVidvan<\/title>\n<meta name=\"description\" content=\"Learn about AVL trees, their need, applications, search, insert &amp; delete operations and implementation of AVL Trees in C, C++, Java &amp; Python.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/techvidvan.com\/tutorials\/avl-tree-in-data-structure\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"AVL Tree in Data Structure - TechVidvan\" \/>\n<meta property=\"og:description\" content=\"Learn about AVL trees, their need, applications, search, insert &amp; delete operations and implementation of AVL Trees in C, C++, Java &amp; Python.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/techvidvan.com\/tutorials\/avl-tree-in-data-structure\/\" \/>\n<meta property=\"og:site_name\" content=\"TechVidvan\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/TechVidvan\/\" \/>\n<meta property=\"article:published_time\" content=\"2021-08-19T03:30:00+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/08\/TV-AVL-tree-in-DS-.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"TechVidvan Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:site\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"TechVidvan Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"17 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"AVL Tree in Data Structure - TechVidvan","description":"Learn about AVL trees, their need, applications, search, insert & delete operations and implementation of AVL Trees in C, C++, Java & Python.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/techvidvan.com\/tutorials\/avl-tree-in-data-structure\/","og_locale":"en_US","og_type":"article","og_title":"AVL Tree in Data Structure - TechVidvan","og_description":"Learn about AVL trees, their need, applications, search, insert & delete operations and implementation of AVL Trees in C, C++, Java & Python.","og_url":"https:\/\/techvidvan.com\/tutorials\/avl-tree-in-data-structure\/","og_site_name":"TechVidvan","article_publisher":"https:\/\/www.facebook.com\/TechVidvan\/","article_published_time":"2021-08-19T03:30:00+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/08\/TV-AVL-tree-in-DS-.jpg","type":"image\/jpeg"}],"author":"TechVidvan Team","twitter_card":"summary_large_image","twitter_creator":"@vidvantech","twitter_site":"@vidvantech","twitter_misc":{"Written by":"TechVidvan Team","Est. reading time":"17 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/techvidvan.com\/tutorials\/avl-tree-in-data-structure\/#article","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/avl-tree-in-data-structure\/"},"author":{"name":"TechVidvan Team","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22"},"headline":"AVL Tree in Data Structure","datePublished":"2021-08-19T03:30:00+00:00","mainEntityOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/avl-tree-in-data-structure\/"},"wordCount":1155,"commentCount":0,"publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/avl-tree-in-data-structure\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/08\/TV-AVL-tree-in-DS-.jpg","keywords":["AVL Tree","AVL Tree in Data Structure","Complexity Analysis of AVL Tree","Deletion in AVL Tree","Implementation of AVL Tree","Insertion in AVL","Rotation in AVL"],"articleSection":["Data Structure Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/techvidvan.com\/tutorials\/avl-tree-in-data-structure\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/techvidvan.com\/tutorials\/avl-tree-in-data-structure\/","url":"https:\/\/techvidvan.com\/tutorials\/avl-tree-in-data-structure\/","name":"AVL Tree in Data Structure - TechVidvan","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/#website"},"primaryImageOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/avl-tree-in-data-structure\/#primaryimage"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/avl-tree-in-data-structure\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/08\/TV-AVL-tree-in-DS-.jpg","datePublished":"2021-08-19T03:30:00+00:00","description":"Learn about AVL trees, their need, applications, search, insert & delete operations and implementation of AVL Trees in C, C++, Java & Python.","breadcrumb":{"@id":"https:\/\/techvidvan.com\/tutorials\/avl-tree-in-data-structure\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/techvidvan.com\/tutorials\/avl-tree-in-data-structure\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/avl-tree-in-data-structure\/#primaryimage","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/08\/TV-AVL-tree-in-DS-.jpg","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/08\/TV-AVL-tree-in-DS-.jpg","width":1200,"height":628,"caption":"AVL tree in Data Structure"},{"@type":"BreadcrumbList","@id":"https:\/\/techvidvan.com\/tutorials\/avl-tree-in-data-structure\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/techvidvan.com\/tutorials\/"},{"@type":"ListItem","position":2,"name":"AVL Tree in Data Structure"}]},{"@type":"WebSite","@id":"https:\/\/techvidvan.com\/tutorials\/#website","url":"https:\/\/techvidvan.com\/tutorials\/","name":"TechVidvan Blogs","description":"","publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/techvidvan.com\/tutorials\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/techvidvan.com\/tutorials\/#organization","name":"TechVidvan","url":"https:\/\/techvidvan.com\/tutorials\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","width":200,"height":50,"caption":"TechVidvan"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/TechVidvan\/","https:\/\/x.com\/vidvantech"]},{"@type":"Person","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22","name":"TechVidvan Team","description":"The TechVidvan Team delivers practical, beginner-friendly tutorials on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our experts are here to help you upskill and excel in today\u2019s tech industry."}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/83522","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/comments?post=83522"}],"version-history":[{"count":0,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/83522\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media\/84125"}],"wp:attachment":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media?parent=83522"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/categories?post=83522"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/tags?post=83522"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}