Interview Questions

Given a binary tree, and 3 values A,B and C.......

Software QA/Tests Interview Questions from Microsoft


(Continued from previous question...)

Given a binary tree, and 3 values A,B and C.......

Q:
Microsoft Interview Question for Software Engineer in Tests about Algorithm br>br> Given a binary tree, and 3 values A,B and C. write an algorithm to check if there exists a path from A to C such that B lies in the path. br>br> Find(Node n,Node req){br> if(n==null)br> return false;br> if(req==A)br> if(n==A)br> return Find(n,B);br> if(req==B)br> if(n==B)br> return Find(n,C);br> if(req==C)br> if(n==C)br> return true;br> elsebr> return Find(n.left,req)||Find(n.right,req);br> }br>

(Continued on next question...)

Other Interview Questions