title: AVL Tree Deletion using Recursion
body: <p>Let x = the node to be deleted</p>
  
  <p>How can I reassign the left or right pointer of x's parent to x's left or right sub tree during rotation without a parent pointer in node's struct declaration using recursion in an AVL Tree Implementation coded in C?</p>
  
  <p>My Node's struct declaration:</p>
  
  <pre><code>typedef struct Node{
      int key;
      struct Node *left;
      struct Node *right;
      int height;
  }node;
  </code></pre>
  
  <p>Currently, these are my rotation codes:</p>
  
  <pre><code>void rotateRight(node **n){
  
      node *lChild = (*n)-&gt;left;
      node *subtree = lChild-&gt;right;
  
      // Rotate Right
      lChild-&gt;right = *n;
      (*n)-&gt;left = subtree;
      *n = lChild;
  
      // Update Height
      lChild-&gt;right-&gt;height = max(getHeight(lChild-&gt;right-&gt;left), getHeight(lChild-&gt;right-&gt;right)) + 1;
      (*n)-&gt;height = max(getHeight((*n)-&gt;left), getHeight((*n)-&gt;right)) + 1;
  }
  
  void rotateLeft(node **n){
  
      node *rChild = (*n)-&gt;right;
      node *subtree = rChild-&gt;left;
  
      // Rotate Left
      rChild-&gt;left = *n;
      (*n)-&gt;right = subtree;
      *n = rChild;
  
      // Update Height
      rChild-&gt;left-&gt;height = max(getHeight(rChild-&gt;left-&gt;left), getHeight(rChild-&gt;left-&gt;right)) + 1;
      (*n)-&gt;height = max(getHeight((*n)-&gt;left), getHeight((*n)-&gt;right)) + 1;
  }
  </code></pre>
  
  <p>When I execute these rotation codes, I lose some elements that should have not been deleted.</p>