Interview at Arista Networks

I was invited for initial round of interview at Arista Networks. It was for a Software Engineer position with networking knowledge and C coding skills. I had the option of (a) interviewing over a phone and coding on a shared screen on emacs [or Vi] editor OR (b) going in to their office for a one hour face-to-face interview. I choose (b).

I scoured internet for interview questions asked at Arista Networks. I got a lot of them mainly they consisted of these:
(a) Writing code on manipulation of binary trees
(b) Writing code on linked lists
(c) General questions on data structures.

Please do your research as there are many people who put up their interview experience at Arista.

I walked in about 15 minutes ahead of schedule. My interviewer was very nice and took me to a small conference room. After initial discussions, we got down to coding/technical questions.

He started a question on Binary Tree [BT]. I realized he was referring to Binary Search Trees. I told him ahead of time that I came prepared on BT as people already know that Arista asks questions on BT. He said that they are aware of such resources but there are ways to test an engineer regardless :)

Q: Lets take an example of BT. Now, can you print the nodes in ascending order?
A: Do inorder traversal.

Q: Please explain?
A: I did and wrote a quick pseudocode.

Q: Can you please do this without recursion?
A: Use a stack to remember nodes that we are not printing and use the same logic as recursion.

Q: Can you explain?
A: When we are traversing the tree, assuming there is no parent pointer, we need a way to remember the un-printed nodes. So, we can use stack for it.

Q: Assuming there is parent pointer for each node, how would you do this?
A: I thought for a while when interviewer intervened and gave the following code.


for (current = min(root); some way to check end of search; current = getnext(current))
printf(current)


Q: Now, please write code for min(root) and getnext(current) functions?
A:
 

min(root)
{ while(root->left != NULL)
root = root->left;
return root;
}


Q: getnext(current) = Given a node, it returns the next node to be printed.
A: I made a huge mess of this code. I finally wrote a working code, but the thinking process was not clear. IMO, this is what they look for: Clarity in thinking, which translates to clean code.

We spent 45 mins on this question alone. Interviewer worked with me throughout the process. I enjoyed bouncing ideas with him. I felt, ultimately, he didn't seem too pleased with my final code.


Q: Given a single linked-list and a node, write code to remove the all occurances of that node.
A: I again made a mess of the code. My code was not clear. In the end, it was working and complete. But I got a feel that the approach to the final code was too laborious.

Overall, I enjoyed my experience as the interviewer was genuinely interested in writing good code and was trying to lead me through the process.

In the end, I couldn't qualify for second round :(

Labels: , , , , ,