Interview Question

Software Engineer Interview(Student Candidate) Redmond, WA

None of the questions were difficult per se. There was

  2 object oriented design questions, 2 array-related questions, and 1 binary tree question. I tripped up on the binary tree question (it was with the last interviewer that flustered me up). It's an easy solution. I got it down conceptually, I just had two more lines of code to put in there. The question was -- Find the common ancestor of two given nodes.
Tags:
technical, analytical, algorithm
Answer

Interview Answer

1 Answer

0

The answer is depth first search and imo, it's probably better to solve it recursively. I showed the guy how the call stack was working and explained depth first search is really the best way to find the most common ancestor. I was left with roughly 20 - 30 minutes to code it up. Plenty of time, but I was already flustered and became even more flustered when I didn't solve it correctly on my first run through.

Study up on the tree algorithms, folks!

Interview Candidate on Feb 5, 2013

Add Answers or Comments

To comment on this, Sign In or Sign Up.