Microsoft Interview Question






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

Breadth first traversal using a queue. First push the parent then its siblings in the queue and each time you pull a node out from the queue add its children to the end of the queue.

- Hemant March 07, 2006 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

It sounds like a heap or a binary heap to me,
and since priority queue sues a heap as the base data structure, r we allowed to use binary max/min heap?

- HotDogMumboJumboDongle March 07, 2006 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

The value of each node is TRUE or FALSE.
The goal is to find the highest-level node that is TRUE.
So what you would do is access each sibling node recursively,
storing the children (if there is one) in a queue.
After accessing all siblings, proceed to pop nodes off the queue and search them recursively.

- Henrick March 07, 2006 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Same as BFS

- Noname January 30, 2007 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

BFS is the only search which looks for the sibling first then children.

- Deepak Garg May 26, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I think we need to do a DFS and NOT BFS...DFS will first cover all siblings before children...comments please

- asdf November 24, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

DFS sounds to be the right choice.

bool Search(node* root, in i)
{
	if(root == NULL)
		return false;
	if( root->data == i || Search(root->next, i) || Search(root->child, i))
		return true;
	return false;
}

- Anonymous January 13, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

BFS using queue will solve the problem

- srik545 January 10, 2012 | 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