Google Interview Question for Software Engineer / Developers






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

Total no. of ways they can move = 2*2*2 = 8
Only 2 ways (clockwise n anticlockwise) not to collide.

Probability for not to collide = 2/8 = 1/4.
To collide = 1-(1/4) = 3/4 = 0.75
:-)

- Hari Prasad Perabattula September 26, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

Out of 8 possibilities there are 2 possibilities where they will never collide ie when they all are moving in the same direction

Therefore probsability 6/8

- DashDash September 27, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

First of all, it says random direction and not necessarily along the edges only. Now we have two cases at hand:
Case-1: We don't know the speed of the ants.
Answer: We can not determine the probability in any way.

Case-2: Assuming constant and equal speeds.
Answer: The ants will meet only when they travel "equal" distance. This essentially means - they will meet only at the centroid of this equilateral triangle! This is the basic logic behind it. I don't know how to show this in terms of probability. But I will try to present a solution - Assuming that each ant can move in 360 directions (based on 360 degrees of a circle), only ONE direction leads to the centroid of the equilateral triangle. This is true for all the three ants. So, it might be said that the probability of their meeting (assuming 360 directions for each ant), is 1/360 * 1/360 * 1/360.

- prakhar November 04, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

And, it nowhere says that meeting of only 2 ants is sufficient. We just want to know when ALL THREE will meet. I strongly feel that Case-2 is the solution they were looking for.

- prakhar November 04, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

I believe this is the solution. Thanks

- lexxx233 December 01, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Boss.. there are infinite directions not 360...ant can move along 2.5 degrees and 3.5 degrees, they still cannot meet

- Anonymous June 10, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

they have to walk around the triangle in the same direction, so as to not collide
so 1/8 , 1/2 * 1/2 * 1/2

- SMK September 25, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Sorry its 1/4 ; because they can decide to move together in the other direction hence 1/8 + 1/8 = 1/4

1/4 is the right answer ( you can write out all the possible combinations or use conditional probability)

- SMK September 25, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

67%. each ant got 2 possibilities. Total is 6 combination. 2 of them cannot meet.

- chicago September 26, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

sorry, wrong. the first answer is right.

- chicago September 26, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

There are 8 possibilities:
L L L
L L R
L R L
L R R
R L L
R L R
R R L
R R R
Because at least 2 ants have the same direction, all 3 will never meet.

- S September 26, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

.. unless when two ants meet they block there, and block the 3rd whichever way he goes. But your answer is more likely, where they just pass.

- JeffD January 15, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

I think, the question is for any of the two to meet.

- Hari Prasad Perabattula September 26, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

1. Any random direction means they don't have to stay on the edges.

2. Even if 1 is not true, it would depend on their speed.

3. If an interviewer cannot frame a question right, they should go fuck themselves.

- memo September 28, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

More likely the incompetence lies with the person who posted the question.

- Ryan October 02, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

As the ants move with the same speed if the move into the triangle they will meet.
as the angle is 60deg in the triangle so the probablity of each ant moving inside triangle is 60/360=1/6

for the three of them
1/6*1/6*1/6

- behnoosh October 12, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Ignore ants behavior, we are not concerned about area of triangle nor how ants will travel nor where or how fast they will travel. All we want to know is the probability of (consider all) ants meeting.

Assuming ant1 meeting ant2 is same as ant2 meeting ant1.

P(All ants will meet) = (number of ways all ants can meet) / (total number of possible events)

Given three ants a1,a2,a3;
The following events are possible
a. None will meet is = organizing each separately = {a1},{a2},{a3} = 1
b. Two will meet     = organizing two elements together = {a1,a2},{a2,a3},{a3,a1} = 3
c. Three will meet   = organizing all together = {a1,a2,a3] = 1

Probability = 1/5 = .2

Maybe I can convince the interviewer with this solution. The interviewer looks at how you are approaching rather than if you got the solution or not, thats what I believe.

- chennavarri October 18, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

- What is the probability of meeting the dinosaur at the center of the city?
- 1/2!
- WHY??
- Either I meet it or not.

- HёLL October 22, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

I think meeting a dinosaur is more like a zero because we can use Bayesian theorem and given that dinosaurs are extinct. The probability is zero. Thanks

- Chennavarri October 22, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

I think it depends on the dino. If its vegetarian the prob is 1/2. else you no longer remain to compute the probability, hence indeterminate.

Maybe someone should dig into the prob of a dino who otherwise is a carnivore is on diet. this will affect the calculation.

- Anonymous April 19, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

u r an idiot.. Plz read the question thoroughly and the dig deep in ur brain and not post random notions tht u thnk is right.. The answer is they cn nvr meet..

- rahul June 14, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

it is 3/4.
Proba that they meet is 1-porbability that they don't meet.
lets calculate the proba that they don't meet :

each can move in 2 directions, which are totally independent so you can multiply...
they are 3, they can move each in two direction :
1/2*1/2*1/2 but this can be in either form left to right or right to Left, so multiply this proba by 2 wich is 1/2*1/2*1/2 *2 = 1/4
remember it is the probability that they don't meet so :

1-1/4 = 3/4

- Anonymous October 22, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Why assume that the triangle has only sides and not a planar area, where ants can move ? Why not consider that the triangle's complement is also a planar area where ants can move, the question never said ants move along the sides of the triangle ?
Why assume ants have equal speed, and not consider variable speeds ?
The question is bogus... and I do not want to spend time on all assumed versions of it...

- Russell February 05, 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