NVIDIA Interview Question for Software Engineer / Developers






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

Breadth first traversal is one of the solution

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

void printTree( Tree *root )
{
std::deque<Tree *> bfsQ;
Tree *node = NULL;

bfsQ.push_back( root );
while ( !bfsQ.empty() ) {
node = bfsQ.front();
node->print();
bfsQ.pop_front();

int outDegree = node->GetNumChildren();
Tree **children = new (Tree*)[outDegree];
node->getChildren( children );
for ( int i = 0; i < outDegree; ++i ) {
node = children[i];
node->print();
bfsQ.push_back( node );
}
}
}

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

Or DFS. Both are of the same type. Use a queue and same stuff can be done.

- Lord Darth Plaguies June 30, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

why .......any traversal (inorder , preorder n post order ) can be done in an iterative fashion .

- Anonymous September 06, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

http://en.wikipedia.org/wiki/Tree_traversal has good examples.

- 3A September 16, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

TreeNode currNode = root;
while (true)
{
if (currNode == null)
break;

if (currNode.Left != null && currNode.Left.Visited != 1)
currNode = currNode.Left;
else if (currNode.Right != null && currNode.Right.Visited != 1)
currNode = currNode.Right;
else if (currNode.Visited == 0)
{
Console.Write(currNode.Value + " ");
currNode.Visited = 1;
}
else
currNode = currNode.Parent;
}

- Anonymous July 28, 2010 | 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