No offence, but the interviewer was from China and it was difficult to understand what she was trying to say... that distracted me almost throughout the interview. Anyway
I was given three class
Node:
Node left;
Node right;
LocalNode(Node):
//
RemoteNode(Node):
//
Q.1 ) Write a code to find the count of "node-chains" of size k.
"node-chains" is defined as a chain of connected parent-child nodes that have only one child.
A. My solution involved recursively calling child nodes from root node and increase height in the recursion call if the node satisfies the condition (only one child node), and reset the height to 0 if it does not. This was easy and the LocalNode class was used, as it denotes nodes that are stored locally
Q.2 ) Since this is a distributed system we also have remote nodes that are on different server. To fetch nodes and its left and right nodes from remote server, it will make rpc calls and be a costly process.
What is an efficient way of performing the same operation (finding count of node-chains of size k) on the remote nodes?
Hint : Approach should minimize rpc calls (fetching nodes)
Now this entire thing was a bit abstract and the second question was completely out of the box for me. I was not expecting a System design like question on my way, since the interviewer suggested me to use map reduce concept to explain implementation for second question.
Anyone else faced MapReduce concept in Onsite interview? Is it acceptable?
Please provide solutions as I couldn't figure it out during the interview obviously.