Untitled
plain_text
2 months ago
357 B
1
Indexable
Never
TreeNode<int> *LCAinaBST(TreeNode<int> *root, TreeNode<int> *P, TreeNode<int> *Q)//hca wouldve been hard { while(root!=NULL){ if(root->data > P->data && root->data > Q->data) { root=root->left; }else if(root->data < P->data && root->data < Q->data) { root=root->right; }else{ return root; } } }