if (node->parent && node->parent->right) {
return node->parent->right;
} else {
return NULL;
}

 

 

 

Given a binary tree with parent pointers, find the right sibling of a given node(pointer to the node will be given), if it doesn’t exist return null. Do it in O(1) space and O(n) time?

Advertisements