National Instruments Interview Question for Software Engineer / Developers






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

1. do a inorder traversal, maintain a static counter for no of elemnts, maintain a static sum variable..your job is done..

- Vishal Goswami. March 04, 2007 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

How to find the loop in a binary tree.

- Sukesh May 08, 2007 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

hahah.. !! trees do not have loops !!

Check the definition of a tree!!

- Sunil Mallya September 06, 2007 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

well, for more than one calls to your function static counter and sum won't work!

- ad November 15, 2007 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Hey, I think it should work...Should not be a problem in this case....

- gauravk.18 March 01, 2008 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

It would work..static member should be defined outside your main or any other functional call just after the pre-processor directives.

- pulsar440 August 21, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Use non recursive DFS or use BFS. Mark a node as visited with BFS and if you come to that again then you are in a loop.

- logan November 21, 2007 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Solution 1: Using Marker byte.
Solution 2: Using Property check, BST condition will fail. left<parent<right
Solution 3: like in Linked list, maintain 2 pointers,
if(ptr1==ptr2) loop detected
for a node call
ptr1 = node->left
ptr2 = node->left->left and also node->left->right
AND
ptr1 = node->right
ptr2 = node->right>left and also node->right>right

- YetAnotherCoder October 02, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Use inorder, preorder or postorder traversal or BFS or DFS to calculate the sum and average. Tree doesn't have loops

- MD March 04, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Use recursion its very simple...to calculate sum and use static variable to calculate the number of nodes available and simple divide them.

The base case for the recursion will be:
{if (head of node is == null) return 0;}

else keep callin the same function with the argument as its child:
else
return (sum(left.child) + sum(right.child) + nodes' value);
and
static variable count = 0; and in each else count++;

- pulsar440 August 21, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

LOL......tree with loop!!!!!!!! :-)

- Anonymous September 12, 2011 | Flag Reply


Add a Comment
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.

Learn More

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.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More