Finding inorder successor of a BST in C Please review this code
I have written a function to find the successor of BST in c. It takes three arguments, i.e root pointer to the binary search tree, node value of which we have to find a successor and parent pointer (for first call it is also root pointer. It will return an integer that is the successor of the node value give.
/**
 * find Successor of BST, complex: o(h)
 * @param rootPtr root pointer of BST
 * @param parent_node parent node of the subtree (root node should be passed by default)
 * @param nodeValue node val to find successor
 * @return succsor
 */
int find_successor_h(BSTNode * rootPtr, int data, BSTNode * parent_node) {
  if (rootPtr == NULL) return data;
  int rt;

  if (data &lt; rootPtr -&gt; data)
    rt = find_successor_h(rootPtr -&gt; left_child, data, rootPtr);
  else if (data &gt; rootPtr -&gt; data)
    rt = find_successor_h(rootPtr -&gt; right_child, data, rootPtr);
  else {
    if (rootPtr -&gt; right_child != NULL)
      return minBST(rootPtr -&gt; right_child);
    else if (rootPtr != parent_node)
      return INT_MIN;
    else
      return data;
  }

  if (rt == INT_MIN)
    return INT_MAX;

  if (rt == INT_MAX)
    return parent_node -&gt; data;
}
Missing return
Code may even fail the last rt == INT_MAX and then no return is specified.
  if (rt == INT_MAX)
    return parent_node -&gt; data;

  // Missing return.
  }

Use const
Using const, as able, provides more information as to what the code does and does not do.  This also allows greater usage and potential optimization.
// int find_successor_h(BSTNode * rootPtr, int data, BSTNode * parent_node) {
int find_successor_h(const BSTNode * rootPtr, int data, const BSTNode * parent_node) {

Mis-matched comments
Comment does not match parameter names nor order: node val vs.  data.
* @param rootPtr root pointer of BST
* @param parent_node parent node of the subtree (root node should be passed by default)
* @param nodeValue node val to find successor

BSTNode * rootPtr, int data, BSTNode * parent_node

Missing include
NULL not defined.
Spelling
* @return succsor vs. * @return successor
Name error?
Why h in int find_successor_h()?
{ block }
Consider using {} even for simple blocks.  Little need for else
//if (rootPtr -&gt; right_child != NULL)
//  return minBST(rootPtr -&gt; right_child);
//else if (rootPtr != parent_node)
//  return INT_MIN;
//else
// return data;

if (rootPtr -&gt; right_child != NULL) {
  return minBST(rootPtr -&gt; right_child);
}
if (rootPtr != parent_node) {
  return INT_MIN;
}
return data;


Deeper review
More support and test drive code needed for a deeper review.