# How do you find out the fifth maximum element in an Binary Search Tree in efficient manner.

Asking BST question, the interviewer is probably looking to see how well you can deal with recursive problems.

/************Below function is for Nth max element ******/

void NthMax(Node *root, int n){

if(root == NULL){

return;

}

max(root->right, n);

if(–n == 0){

cout<<"Number is: "<

}

int main()

{

/* for 5th max pass 5 in NthMax(..) ***/

}

## Leave a Reply