Doubt doubt doubt

Problem???

hi… just simply do the inorder traversal of tree and store all the elements in a vector/array… then iterate over the array and if the value lies within the given range then simply print it…

ohh… mene quesiton galat samajh liya tha. By the way, can you tell why my code is not working for LCA…??

bool *FindAnces(node root, int k1, int k2,node &lca)

{

if (root == NULL){

    return false;

}

if (root->data == k1 or root->data == k2){

    lca = root;

    return true;

}

bool lside = FindAnces(root->left, k1, k2,lca);

bool rside = FindAnces(root->right, k1, k2,lca);

if (lside && rside){

    lca = root;

    return true;

}

return rside || lside;

}

i have made changes for ur lca code… but in addition to this u would also have to check if nodes k1 and k2 are present in tree or not… if any one is missing then simply ur ans would be NULL

for the ques find nodes in given range u can refer to my code https://ide.codingblocks.com/s/601272

I hope ur doubt is cleared now???