Amazon Interview Question for Software Engineer / Developers


Country: United States
Interview Type: Phone Interview




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

static void bfs(BinaryTreeNode node) {
Queue<BinaryTreeNode> queue = new LinkedList<BinaryTreeNode>();

queue.add(node);

while (!queue.isEmpty()) {
BinaryTreeNode tmp = queue.poll();

System.out.println(tmp.data.getSsn() + "~" + tmp.data.getName());

if (tmp.left != null) { queue.add(tmp.left);}
if (tmp.right != null) { queue.add(tmp.right);}
}

}

- pdhingra December 27, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

looking at the node structure , question is not clear..please check once again .

- zeroByzero December 27, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I dont remember properly but i'm sure it was just BFS implementaion and also asked me
Which datastructure u use to keep track of visited nodes..? ans: HashMap

- Minnu December 27, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Are you sure it was tree and not graph?
did you ask question, why in tree you would like to keep track of visited nodes? In tree we dont need to keep track of visited nodes as we only visit each node once.

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

@Minnu,

Are you sure it was tree? and NOT GRAPH.
If tree did you ask why we need to keep track of visited nodes? In tree each node is visited only once.

- xyz December 27, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

not tree..it's a graph

- Minnu December 27, 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