Cisco Systems Interview Question
Software Engineer / Developers2. Take 1 coin from the first, 2 from second, 3 from third..., and weigh them all together
if total weight = x grams, then (5500-x)/10 is the stack number.
All assuming a digital scale. If we have a weighing balance then I believe its much easier problem
this is wrong calculation.
lets say there are 3 stacks. 2nd one is faulty.
Now we have 1 from 1st, 2 from 2nd, 3 from 3rd.
Total : 100+90*2+100*3=580.
Actual=600.
faulty_diff=100-90=10
stack no= (Actual-Total)faulty_diff
=(600-580)/10
=2.
Ashpiy. Read the question again. The 2nd question is based on 1st. The question is for 10 stacks and so the answer.
1) Divide into 5 and 5
2) Divide 5 into 2, 2, and 1. Weight 2 and 2.
If 2 and 2 are equal, then 1 is the answer.
If 2 is less, then
3) weigh the ones in 2, get the answer
This is 3 iteration only. but we can improve this approach.
1) first take 4 and 4 (keep 2 separate)
if both are equal then measure these 2 only. (only 2 iteration)
2) if those 4 and 4 are not equal then take lighter one.
now instead of 2 and 2 take any 1 and 1. if they are unequal, it solves the problem. (again only 2 iterations).
3) now if 1 and 1 are also equal then compare rest of two.
this is the worst case when we need 3 iteration.
LOL
Take 4 and 4 and how do you know both are equal. Do you measure twice??
That's already 2 iterations. Now if both are not equal then find the one from 4 using only 1 iteration. Dude read ur answer again.
^^
ashpiy is correct
u r duhh man
take random 8 stacks
put 4 on one side and 4 on the other side (1st weighing)
if they are equal means it is either one of the remaining 2
so u will get answer in second iteration itself
but if they are not then we wont check the remaining 2 so it is still one iteration for this particular scenario
so for second iteration for this particular scenario i will consider the stack which weighed less in the first scenario because it says one stack is lesser then rest others
so now i have 4 stacks left with me
i will put 2 on both the sides (2nd iteration for this case)
then i think it is easy and u wont have any baseless arguements
be polite when u r not better then others
or in your case SELF REALIZATION !!
For Question 1.a)Divide 10=3+3+3+1.
b).if first two 3 and 3 are unequal, you can get the faulty of 3 and take that bunch and have 1 and 1 and you get to know the faulty one.
c).If first two 3 and 3 are equal,3+1=4 and divide it in 2+2 and you can get the faulty of 2 and repeat for the 1.
For Question 1.
- arindamkar1981 November 17, 2010a)Divide 10=3+3+3+1.
b).if first two 3 and 3 are unequal, you can get the faulty of 3 and take that bunch and have 1 and 1 and you get to know the faulty one.
c).If first two 3 and 3 are equal,3+1=4 and divide it in 2+2 and you can get the faulty of 2 and repeat for the 1.