## CapitalIQ Interview Question for Software Engineer / Developers

Comment hidden because of low score. Click to expand.
0
of 0 vote

If p!=q, reduce to LCA problem
If p==q, DFS to find the parent of p

Comment hidden because of low score. Click to expand.
0
of 0 vote

even in case of p==q its same as the lca

Comment hidden because of low score. Click to expand.
0
of 0 vote

in both the cases => LCA problem

Comment hidden because of low score. Click to expand.
0
of 0 vote

what does LCA means

Comment hidden because of low score. Click to expand.
0

LCA means Least Common Ancestor

Comment hidden because of low score. Click to expand.
0
of 0 vote

does anyone knw the questions for technology Quality Analyst....i need dem vry urgent..plz tell asap....

Comment hidden because of low score. Click to expand.
0
of 0 vote

suggest algo 4 lca

Comment hidden because of low score. Click to expand.
0
of 0 vote

tree *least(tree *node,int val1,int val2)
{
tree *current=node;
while(1)
{
if(current->data<val1&&current->data<val2)
{
if(current->right->data==val1||current->right->data==val2)
return current;
else
current=current->right;
}
else if(current->data>val1&&current->data>val2)
{
if(current->left->data==val1||current->left->data==val2)
return current;
else
current=current->left;
}
else
return current;
}
}

Comment hidden because of low score. Click to expand.
0
of 0 vote

@laasya1991
i think this code works only for binary search tree, and what if one value is present and one is not in our tree?

Comment hidden because of low score. Click to expand.
0
of 0 vote

Btree* least(Btree *b ,int k1,int k2)
{
if(contains(b->lc,k1)&&contains(b->rc,k2) || contains(b->lc,k2)&&contains(b->rc,k1))
{
return b;
}
else if(contains(b->lc,k1)&&contains(b->lc,k2))
return least(b->lc,k1,k2);
else
return least(b->rc,k1,k2);
}

bool contains(Btree *bt,int k)
/* level order traversal to find whether node containing value k is present or not */
{
arrayQueue <Btree *> q; //queue of binary tree nodes
while(bt!=NULL)
{
if(bt->d==k)
return true;
//put bt's child on queue
if(bt->lc!=NULL)
q.push(bt->lc);
if(bt->rc!=NULL)
q.push(bt->rc);
//get next node to visit
try{
bt=q.front();
}
catch(queueEmpty){
return false;
}
q.pop();
}

}

Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

### Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

### Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.