Jun 112012
 

Given a pointer to the node in a binary tree, write code to find its inorder successor. You may assume each node to also have a pointer to the parent node (along with pointer to right and left sub-trees). Hence, the structure of Node will be

struct Node
{
    int data;
    Node* lptr;    // pointer to the left subtree
    Node* rptr;    // pointer to the right subtree
    Node* parent;  // Pointer to the parent Node (null for root of tree)
};

Continue reading »