Chèn 1 nút vào cây có sẵn

nodeptr insert_node(nodeptr &root , int x)
{
   nodeptr p =make_node(x) ;
   nodeptr q,f;
   if(root == NULL)
   {
      root = p;
   }
   else
   {
      root = q;
    `  f=NULL;`
      while(q!=NULL)
      {
         f = q;
         if(x < q ->data)
         {
            q = q->left;
         }
         else
         {
            q = q->right;
         }
      }
      if(x < f->data)
      {
         f->left = p;
      }
      else
      {
         f->right = p;
      }
   }
   return p;
}

m.n giải thích giúp e chỗ f = Null được không

83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?