National Instruments Interview Question for Software Engineer / Developers






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

We can use a recursive function along with static storage for the summation such that value is retained between successive call to the function.
This method first computer over left subtree and then on right subtree of the Root of the binary tree.. static specifier maintain the value between recursive calls..

void average(node* start)
{
static int average = 0;
if(start!= NULL)
{
Add(node->left);
Add(node->right);
result += node->value;
}
}

- veb October 17, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

do a inorder traversal on binary tree and suming up all integer in node as well keep count of nodes as well.

- sushantmax88 January 03, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

void average(node *Start)
{
static int result=0;
static int count=0;
int average=0;
if(start !=null)
{
average(Start->left);
result+=Start->data;
count++;
average(Start->right);
}
average=(result)/count;

}

- Anonymous August 21, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

@Anonymous: Should the static variables be not declared as global???

- pshankar87 December 09, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

struct node
{
int info;
struct node *link;
}
typedef struct node *NODE;

void average(NODE first)
{
NODE temp;
temp=first;
int sum=0,n=0;
float avg=0.0;
do
{
sum=sum+temp->info;
temp=temp->link;
n++;
}
while(temp->link!=NULL)
avg=sum/n;
printf("average  = %f",avg);
}
}

- Anonymous August 19, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

@Anonymous: u have given the solution for a linked list. The question is to find the 'average for a BST'

- pshanka87 December 09, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

public float meanvalue(int[] graph, int i)
{
float mean = 0 ;
int count = 0 ;
for all node in graph{
node.visit = false;
}
stack.push(i);
while(!stack.empty())
{
p <- stack.pop()
if(p is not visited)
{
visited[p] = true;
count++ ;
mean = mean + p.value;
for each neighbor p:
stack.push(p.neighbor)
}

}
mean = mean/ count;
return mean;
}

- mohammad.dibay April 04, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

int CalculateAverage(stTree* pRoot)
{
int nCount = 0;
return CalculateSumNCount(pRoot,nCount)/nCount;
}

int CalculateSumNCount(stTree* pRoot,int& count)
{
if(pRoot == NULL)
return 0;
count++;
return (pRoot->data + CalculateSumNCount(pRoot->left,count) + CalculateSumNCount(pRoot->right,count));
}

- Anonymous April 24, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I am an IT Recruiter looking for some Software Engineers in the Austin area contact me directly--client has asked that I recruit specifically for National Candidates candidates suzie.jimenez@thehtgroup.com 512.345.9300

- suziejimenez3 September 25, 2014 | 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