1.) There is an apple inside the bottle whose nozzle is very small than apple size, You cannot take the apple from the bottle. How that apple went inside or how the bottle is manufactured with the apple ?
Ans:
When that apple was small in the apple tree, it was sent inside the bottle and tied to the apple tree, so the apple was remain inside the bottle till it grows to bigger size
2.) There is a bridge, 4 people are standing at one end, they have one torch, they are trying to come to the other end, the question here is how soon they can come by the following criterias
a) At a time only 2 can travel with that torch,
b) without the torch they cannot travel.
c) After reaching the other end, one of them should come back with the torch so that it will be used again
those four travels in different speed, time taken by each of them is as follows,
1 min, 2 min, 10 min, 5 min,
When 2 of them comes to the other end the time taken by them is the maximum
that is for example if 10 and 1 are going together, then time taken is 10 min
Final question is that they all should come to the other end within 17 min, how can they come ?
Answer:
step-1: 1, 2 went to the other end and 1 returns back, so time is = 3
step-2: 10, 5 went to the other end and 2 returns back, so time is = 12
step-3: 1, 2 went to the other end, so time is = 2
Finally 3 + 12 + 2 = 17 mins
3.) there are 3 bags A, B, C. Bag A contains 50 oranges, but labeled as apples, Bag B contains 50 apples but labeled as oranges, but the third bag C contains 100 apples and oranges mix but labeled as (oranges and apples), these 3 bags are in front of you, you should take minimum number of fruits from any of the bags randomly and you should identify those 3 bags.
Ans: 2
steps:
lets take x and y are first and second fruits, taken from A or B or C,
considering the following options the answer is 2.
option-1
x = apple from A, A contains orange
y = orange from B, B contains apple
then C contains the mix
option-2
x = apple from B, B contains orange
y = mix from C, C contains mix
A contains the apple
The other way around, the minimum try needed is only 2
4.) Write steps to calculate tax for a salary, like this
a) upto 99 no tax
b) 100 to 199 10%
c) 200 to 299 20%
d) above 300 30%
Ans:
lets take salary as s, now apply the follow steps
if s < 100
tax = 0;
else if s < 200
tax = (s - 100) * 0.1
else if s < 300
tax = (s - 100) * 0.2 + 10
else above 300
tax = (s - 200) * 0.3 + 20 + 10
5.) Write a Binary search algorithm
No comments:
Post a Comment