## Facebook Interview Question Software Engineer / Developers

• 0

Given a set of points (x,y) in a 2-d plane, which are guesses of a particular unknown point (x',y'), how do find the best estimate of (x',y') using the set of points given.

Country: United States
Interview Type: In-Person

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

the question is simple. you need to know the guessing pattern. If not available the best way is to think of it as finding the average of the cluster of the sample points given after identifying the outliers. To find these clusters use a density based clustering algorithm. If a single cluster is formed, print its mean, but if there is more than 1 clusters are found the number could be the centroid of any of these clusters. Hence, in case of more clusters the result will not necessarily give you the right answer.

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

What kind of guesses? How were these guesses formed?

Comment hidden because of low score. Click to expand.
0

Good.

You need to know the underlying distribution of the guessing process.

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

How about just taking the averages? If there are n given points (x', y') = (sum(x)/n, sum(y)/n).

Comment hidden because of low score. Click to expand.
0
of 2 vote

I believe it could be solved by Expectation Maximization method.

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

fentoyal -- I wrote the answer in the name field.

Comment hidden because of low score. Click to expand.
0

Center of mass...implies some kind of weighting. How would you derive such, or is every point weighted the same? In that case, your answer is no different from that of the person who suggested taking the average. I still think that the only reasonable answer based on what's given in the question is to ask "well, what's the distribution of the guessing process?"

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

best guess is the average point
x'=sum of all xs divided by the number of points
y'=sum of all ys divided by the number of points

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

maybe we can firstly find the mean using k-means, then calculate the average distance among all other points and the mean?

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

You can mathematically prove that the optimal solution is [sum(x)/n , sum(y)/n].

I just can't figure out a way to type it out here though. Let me give it a try

You can try to minimize summation((x-x')^2) + summation((y-y')^2) and take partial derivatives on x and y. You get 2 equations. Upon solving them you get the optimal solution to be what is mentioned above.

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

Typical machine learning regression problem.
You can use a bunch of method like Linear regression or Neuron Network.

Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0

The whole point of this question is that you don't have original point x, y

Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

### Books

is a comprehensive book walking you through every aspect of getting a job at a top tech company, while focuses on software engineering interviews.

### 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.