Monday, April 13, 2015

Install Cloudera Hadoop CDH5 with YARN on Ubuntu


This tutorial describes how to install and configure a single-node Hadoop cluster on Ubuntu OS. Single Node Hadoop cluster is also called as Hadoop Pseudo-Distributed Mode. The tutorial is very simple and to the point, so that you can install Hadoop in 10 Min. Once the installation is done you can perform Hadoop Distributed File System (HDFS) and Hadoop Map-Reduce operations.

Recommended Platform:

  • OS: Linux is supported as a development and production platform. You can use Ubuntu 14.04 or later (you can also use other Linux flavors like: CentOS, Redhat, etc.)
  • Hadoop: Cloudera Distribution for Apache hadoop CDH5.x (you can use Apache hadoop 2.x)


Install Java 7 (Recommended Oracle Java)

Install Python Software Properties

$sudo apt-get install python-software-properties

Add Repository

$sudo add-apt-repository ppa:webupd8team/java

Update the source list

$sudo apt-get update

Install Java

$sudo apt-get install oracle-java7-installer

Configure SSH

Install Open SSH Server-Client

$sudo apt-get install openssh-server openssh-client

Generate Key Pairs

$ssh-keygen -t rsa -P ""

3.2.3 Configure password-less SSH

$cat $HOME/.ssh/ >> $HOME/.ssh/authorized_keys

Check by SSH to localhost

$ssh localhost

Install Hadoop

Download Hadoop

Untar Tar ball

$tar xzf hadoop-2.5.0-cdh5.3.2.tar.gz
Note: All the required jars, scripts, configuration files, etc. are available in HADOOP_HOME directory (hadoop-2.5.0-cdh5.3.2)

Friday, January 23, 2015

Infosys Quiz Part - 1

1.Three friends divided some bullets equally. After all of them shot 4 bullets the total number
of bullets remaining is equal to the bullets each had after division. Find the original number
2.Find sum of digits of D.
Let A= 19991999
B = sum of digits of A, C = sum of digits of B, D = sum of digits of C. (HINT: A = B = C = D (mod
3.There is a 50m long army platoon marching ahead. The last person in the platoon wants to give
a letter to the first person leading the platoon. So while the platoon is marching he runs ahead,
reaches the first person and hands over the letter to him and without stopping he runs and
comes back to his original position.
In the mean time the whole platoon has moved ahead by 50m.
The question is how much distance did the last person cover in that time. Assuming that he ran
the whole distance with uniform speed.
4.If you take a marker & start from a corner on a cube, what is the maximum number of edges
you can trace across if you never trace across the same edge twice, never remove the marker
from the cube, & never trace anywhere on the cube, except for the corners & edges? 9
5.One of Mr. Bajaj, his wife, their son and Mr. Bajaj's mother is an Engineer and another is a
If the Doctor is a male, then the Engineer is a male.
If the Engineer is younger than the Doctor, then the Engineer and the Doctor are not blood
If the Engineer is a female, then she and the Doctor are blood relatives.
Can you tell who is the Doctor and the Engineer?
Doc is
6.Three men - Sam, Cam and Laurie - are married to Carrie, Billy and Tina, but not necessarily in
the same order.
Sam's wife and Billy's Husband play Carrie and Tina's husband at bridge. No wife partners her
husband and Cam does not play bridge.
Who is married to Cam?
Cam carrie
7.There are 3 persons X, Y and Z. On some day, X lent tractors to Y and Z as many as they had.
After a month Y gave as many tractors to X and Z as many as they have. After a month Z did
the same thing. At the end of this transaction each one of them had 24.
Find the tractors each originally had?
8.A certain street has 1000 buildings. A sign-maker is contracted to number the houses from 1
to 1000. How many zeroes will he need?
9.There are 9 coins. Out of which one is odd one i.e weight is less or more. How many iterations
of weighing are required to find odd coin?
10.In a sports contest there were m medals awarded on n successive days (n > 1).
On the first day 1 medal and 1/7 of the remaining m - 1 medals were awarded.
On the second day 2 medals and 1/7 of the now remaining medals was awarded; and so on.
On the nth and last day, the remaining n medals were awarded.
How many days did the contest last, and how many medals were awarded altogether?
11.A number of 9 digits has the following properties:
The number comprising the leftmost two digits is divisible by 2, that comprising the leftmost
three digits is divisible by 3, the leftmost four by 4, the leftmost five by 5, and so on for the
nine digits of the number i.e. the number formed from the first n digits is divisible by n,
Each digit in the number is different i.e. no digits are repeated.
The digit 0 does not occur in the number i.e. it is comprised only of the digits 1-9 in some order.
Find the number.
12. 1/3 rd of the contents of a container evaporated on the 1st day. 3/4th of the remaining
contents of the container evaporated on the second day.
What part of the contents of the container is left at the end of the second day?
(x-1/3x)-((x-1/3x)3/4)=2/3x-1/2x= 1/6x
13.Vipul was studying for his examinations and the lights went off. It was around 1:00 AM. He
lighted two uniform candles of equal length but one thicker than the other. The thick candle is
supposed to last six hours and the thin one two hours less. When he finally went to sleep, the
thick candle was twice as long as the thin one.
For how long did Vipul study in candle light? 3 hrs
14.If you started a business in which you earned Rs.1 on the first day, Rs.3 on the second day,
Rs.5 on the third day, Rs.7 on the fourth day, & so on.
How much would you have earned with this business after 50 years (assuming there are exactly
365 days in every year)?
Math gurus may use series formula to solve it.(series: 1,3,5,7,9,11.....upto 18250 terms)
15.A worker earns a 5% raise. A year later, the worker receives a 2.5% cut in pay, & now his
salary is Rs. 22702.68
What was his salary to begin with?
16.At 6'o a clock ticks 6 times. The time between first and last ticks is 30 seconds. How long
does it tick at 12'o.
17. 500 men are arranged in an array of 10 rows and 50 columns according to their heights.
Tallest among each row of all are asked to come out. And the shortest among them is A.
Similarly after resuming them to their original positions, the shortest among each column are
asked to come out. And the tallest among them is B.
Now who is taller A or B? a&b same person
18.In Mr. Mehta's family, there are one grandfather, one grandmother, two fathers, two
mothers, one father-in-law, one mother-in-law, four children, three grandchildren, one brother,
two sisters, two sons, two daughters and one daughter-in-law. How many members are there in
Mr. Mehta's family? Give minimal possible answer. 7
19.When Alexander the Great attacked the forces of Porus, an Indian soldier was captured by
the Greeks. He had displayed such bravery in battle, however, that the enemy offered to let
him choose how he wanted to be killed. They told him, "If you tell a lie, you will put to the sword,
and if you tell the truth you will be hanged."
The soldier could make only one statement. He made that statement and went free. What did he
20.A person wanted to withdraw X rupees and Y paise from the bank. But cashier made a
mistake and gave him Y rupees and X paise. Neither the person nor the cashier noticed that.
After spending 20 paise, the person counts the money. And to his surprise, he has double the
amount he wanted to withdraw.
Find X and Y. (1 Rupee = 100 Paise)
21.The game of Tic-Tac-Toe is being played between two players. Only the last mark to
be placed in the game as shown.
Who will win the game, O or X? Can you tell which was the sixth mark and at which position? Do
explain your answer.
Assume that both the players are intelligent enough.
22At the Party:
There were 9 men and children.
There were 2 more women than children.
The number of different man-woman couples possible was 24. Note that if there were 7 men
and 5 women, then there would have been 35 man-woman couples possible.
Also, of the three groups - men, women and children - at the party:
There were 4 of one group.
There were 6 of one group.
There were 8 of one group.
Exactly one of the above 6 statements is false.
Can you tell which one is false? Also, how many men, women and children are there at the party
23There is a shortage of tube lights , bulbs and fans in a village - Kharghar. It is found that
All houses do not have either tubelight or bulb or fan.
exactly 19% of houses do not have just one of these.
atleast 67% of houses do not have tubelights.
atleast 83% of houses do not have bulbs.
atleast 73% of houses do not have fans.
What percentage of houses do not have tubelight, bulb and fan?

23.Mr. Subramaniam rents a private car for Andheri-Colaba-Andheri trip. It costs him Rs. 300
One day the car driver informed Mr. Subramaniam that there were two students from Bandra
who wished to go from Bandra to Colaba and back to Bandra. Bandra is halfway between Andheri
and Colaba. Mr. Subramaniam asked the driver to let the students travel with him.
On the first day when they came, Mr. Subramaniam said, "If you tell me the mathematically
correct price you should pay individually for your portion of the trip, I will let you travel for
How much should the individual student pay for their journey?
1. 18
Assume that initial there were 3*X bullets.
So they got X bullets each after division.
All of them shot 4 bullets. So now they have (X - 4) bullets each.
But it is given that, after they shot 4 bullets each, total number of bullets remaining is equal to
the bullets each had after division i.e. X
Therefore, the equation is
3 * (X - 4) = X
3 * X - 12 = X
2 * X = 12
X = 6
Therefore the total bullets before division is = 3 * X = 18
2. The sum of the digits of D is 1.
Let E = sum of digits of D.
It follows from the hint that A = E (mod 9)
A = 19991999
< 20002000
= 22000 * 10002000
= 1024200 * 106000
< 10800 * 106000
= 106800
i.e. A < 106800
i.e. B < 6800 * 9 = 61200
i.e. C < 5 * 9 = 45
i.e. D < 2 * 9 = 18
i.e. E <= 9
i.e. E is a single digit number.
1999 = 1 (mod 9)
so 19991999 = 1 (mod 9)
Therefore we conclude that E=1.

3.The last person covered 120.71 meters.
It is given that the platoon and the last person moved with uniform speed. Also, they both
moved for the identical amount of time. Hence, the ratio of the distance they covered - while
person moving forward and backword - are equal.
Let's assume that when the last person reached the first person, the platoon moved X meters
Thus, while moving forward the last person moved (50+X) meters whereas the platoon moved X
Similarly, while moving back the last person moved [50-(50-X)] X meters whereas the platoon
moved (50-X) meters.
Now, as the ratios are equal,
(50+X)/X = X/(50-X)
(50+X)*(50-X) = X*X
Solving, X=35.355 meters
Thus, total distance covered by the last person
= (50+X) + X
= 2*X + 50
= 2*(35.355) + 50
= 120.71 meters
Note that at first glance, one might think that the total distance covered by the last person is
100 meters, as he ran the total length of the platoon (50 meters) twice. TRUE, but that's the
relative distance covered by the last person i.e. assuming that the platoon is stationary.
4. Ans.9
To verify this, you can make a drawing of a cube, & number each of its 12 edges. Then, always
starting from 1 corner & 1 edge, you can determine all of the possible combinations for tracing
along the edges of a cube.
There is no need to start from other corners or edges of the cube, as you will only be repeating
the same combinations. The process is a little more involved than this, but is useful for solving
many types of spatial puzzles.
Mr. Bajaj is the Engineer and either his wife or his son is the Doctor.
Mr. Bajaj's wife and mother are not blood relatives. So from 3, if the Engineer is a female, the
Doctor is a male. But from 1, if the Doctor is a male, then the Engineer is a male. Thus, there is
a contradiction, if the Engineer is a female. Hence, either Mr. Bajaj or his son is the Engineer.
Mr. Bajaj's son is the youngest of all four and is blood relative of each of them. So from 2, Mr.
Bajaj's son is not the Engineer. Hence, Mr. Bajaj is the Engineer.
Now from 2, Mr. Bajaj's mother can not be the Doctor. So the Doctor is either his wife or his
son . It is not possible to determine anything further.
Carrie is married to Cam.
"Sam's wife and Billy's Husband play Carrie and Tina's husband at bridge."
It means that Sam is not married to either Billy or Carrie. Thus, Sam is married to Tina.
As Cam does not play bridge, Billy's husband must be Laurie.
Hence, Carrie is married to Cam.
One way to solve it is by making 3 equations and solve them simultaneously. But there is rather
easier way to solve it using Backtracing.
It's given that at the end, each had 24 tractors (24, 24, 24) i.e. after Z gave tractors to X & Y
as many as they had. It means that after getting tractors from Z their tractors got doubled. So
before Z gave them tractors, they had 12 tractors each and Z had 48 tractors. (12, 12, 48)
Similarly, before Y gave tractors to X & Z, they had 6 & 24 tractors respectively and Y had 42
tractors i.e. (6, 42, 24)
Again, before X gave tractors to Y & Z, they had 21 & 12 tractors respectively and X had 39
tractors i.e. (39, 21, 12)
Hence, initially X had 39 tractors, Y had 21 tractors and Z had 12 tractors.
The sign-maker will need 192 zeroes.
Divide 1000 building numbers into groups of 100 each as follow:
(1..100), (101..200), (201..300), ....... (901..1000)
For the first group, sign-maker will need 11 zeroes.
For group numbers 2 to 9, he will require 20 zeroes each.
And for group number 10, he will require 21 zeroes.
The total numbers of zeroes required are
= 11 + 8*20 + 21
= 11 + 160 + 21
= 192
It is always possible to find odd coin in 3 weighings and to tell whether the odd coin is heavier
or lighter.
Take 8 coins and weigh 4 against 4.
If both are not equal, goto step 2
If both are equal, goto step 3
One of these 8 coins is the odd one. Name the coins on heavier side of the scale as H1, H2, H3
and H4. Similarly, name the coins on the lighter side of the scale as L1, L2, L3 and L4. Either one
of H's is heavier or one of L's is lighter. Weigh (H1, H2, L1) against (H3, H4, X) where X is one
coin remaining in intial weighing.
If both are equal, one of L2, L3, L4 is lighter. Weigh L2 against L3.
If both are equal, L4 is the odd coin and is lighter.
If L2 is light, L2 is the odd coin and is lighter.
If L3 is light, L3 is the odd coin and is lighter.
If (H1, H2, L1) is heavier side on the scale, either H1 or H2 is heavier. Weight H1 against H2
If both are equal, there is some error.
If H1 is heavy, H1 is the odd coin and is heavier.
If H2 is heavy, H2 is the odd coin and is heavier.
If (H3, H4, X) is heavier side on the scale, either H3 or H4 is heavier or L1 is lighter. Weight
H3 against H4
If both are equal, L1 is the odd coin and is lighter.
If H3 is heavy, H3 is the odd coin and is heavier.
If H4 is heavy, H4 is the odd coin and is heavier.
The remaining coin X is the odd one. Weigh X against the anyone coin used in initial weighing.
If both are equal, there is some error.
If X is heavy, X is the odd coin and is heavier.
If X is light, X is the odd coin and is lighter.
Total 36 medals were awarded and the contest was for 6 days.
On day 1: Medals awarded = (1 + 35/7) = 6 : Remaining 30 medals
On day 2: Medals awarded = (2 + 28/7) = 6 : Remaining 24 medals
On day 3: Medals awarded = (3 + 21/7) = 6 : Remaining 18 medals
On day 4: Medals awarded = (4 + 14/7) = 6 : Remaining 12 medals
On day 5: Medals awarded = (5 +7/7) = 6 : Remaining 6 medals
On day 6: Medals awarded 6
I got this answer by writing small program. If anyone know any other simpler method, do submit
11.The answer is 381654729
One way to solve it is Trial-&-Error. You can make it bit easier as odd positions will always
occupy ODD numbers and even positions will always occupy EVEN numbers. Further 5th position
will contain 5 as 0 does not occur.
The other way to solve this problem is by writing a computer program that systematically tries
all possibilities
Assume that contents of the container is X
On the first day 1/3rd is evaporated.
(1 - 1/3) of X is remaining i.e. (2/3)X
On the Second day 3/4th is evaporated. Hence,
(1- 3/4) of (2/3)X is remaining
i.e. (1/4)(2/3)X = (1/6) X
Hence 1/6th of the contents of the container is remaining
Vipul studied for 3 hours in candle light.
Assume that the initial lenght of both the candle was L and Vipul studied for X hours.
In X hours, total thick candle burnt = XL/6
In X hours, total thin candle burnt = XL/4
After X hours, total thick candle remaining = L - XL/6
After X hours, total thin candle remaining = L - XL/4
Also, it is given that the thick candle was twice as long as the thin one when he finally went to
(L - XL/6) = 2(L - XL/4)
(6 - X)/6 = (4 - X)/2
(6 - X) = 3*(4 - X)
6 - X = 12 - 3X
2X = 6
X = 3
Hence, Vipul studied for 3 hours i.e. 180 minutes in candle light.
To begin with, you want to know the total number of days: 365 x 50 = 18250.
By experimentation, the following formula can be discovered, & used to determine the amount
earned for any particular day: 1 + 2(x-1), with x being the number of the day. Take half of the
18250 days, & pair them up with the other half in the following way: day 1 with day 18250, day 2
with day 18249, & so on, & you will see that if you add these pairs together, they always equal
Multiply this number by the total number of pairs (9125), & you have the amount you would have
earned in 50 years.
Assume his salary was Rs. X
He earns 5% raise. So his salary is (105*X)/100
A year later he receives 2.5% cut. So his salary is ((105*X)/100)*(97.5/100) which is Rs.
Hence, solving equation ((105*X)/100)*(97.5/100) = 22702.68
X = 22176
66 seconds
It is given that the time between first and last ticks at 6'o is 30 seconds.
Total time gaps between first and last ticks at 6'o = 5
(i.e. between 1 & 2, 2 & 3, 3 & 4, 4 & 5 and 5 & 6)
So time gap between two ticks = 30/5 = 6 seconds.

Now, total time gaps between first and last ticks at 12'o = 11
Therefore time taken for 12 ticks = 11 * 6 = 66 seconds (and not 60 seconds)
No one is taller, both are same as A and B are the same person.
As it is mentioned that 500 men are arranged in an array of 10 rows and 50 columns according
to their heights. Let's assume that position numbers represent their heights. Hence, the
shortest among the 50, 100, 150, ... 450, 500 is person with height 50 i.e. A. Similarly the tallest
among 1, 2, 3, 4, 5, ..... 48, 48, 50 is person with height 50 i.e. B
Now, both A and B are the person with height 50. Hence both are same.
There are 7 members in Mr. Mehta's family. Mother & Father of Mr. Mehta, Mr. & Mrs. Mehta,
his son and two daughters.
Mother & Father of Mr. Mehta
Mr. & Mrs. Mehta
One Son & Two Daughters
The soldier said, "You will put me to the sword."
The soldier has to say a Paradox to save himself. If his statement is true, he will be hanged,
which is not the sword and hence false. If his statement is false, he will be put to the sword,
which will make it true. A Paradox !!!
As given, the person wanted to withdraw 100X + Y paise.
But he got 100Y + X paise.
After spending 20 paise, he has double the amount he wanted to withdraw. Hence, the equation
2 * (100X + Y) = 100Y + X - 20
200X + 2Y = 100Y +X - 20
199X - 98Y = -20
98Y - 199X = 20
Now, we got one equation; but there are 2 variables. We have to apply little bit of logic over
here. We know that if we interchange X & Y, amount gets double. So Y should be twice of X or
one more than twice of X i.e. Y = 2X or Y = 2X+1
Case I : Y=2X
Solving two equations simultaneously
98Y - 199X = 20
Y - 2X = 0
We get X = - 20/3 & Y = - 40/2
Case II : Y=2X+1
Solving two equations simultaneously
98Y - 199X = 20
Y - 2X = 1
We get X = 26 & Y = 53
Now, its obvious that he wanted to withdraw Rs. 26.53
O will win the game. The sixth mark was X in square 9.
The 7th mark must be placed in square 5 which is the win situation for both X and O. Hence, the
6th mark must be placed in a line already containing two of the opponents marks. There are two
such possibilities - the 6th mark would have been either O in square 7 or X in square 9.
As we know both the players are intelligent enough, the 6th mark could not be O in square 7.
Instead, he would have placed O in square 5 and would have won.
Hence, the sixth mark must be X placed in square 9. And the seventh mark will be O. Thus O will
win the game.
Statement (4) is false. There are 3 men, 8 women and 6 children.
Assume that Statements (4), (5) and (6) are all true. Then, Statement (1) is false. But then
Statement (2) and (3) both can not be true. Thus, contradictory to the fact that exactly one
statement is false.
So Statement (4) or Statement (5) or Statement (6) is false. Also, Statements (1), (2) and (3)
all are true.
From (1) and (2), there are 11 men and women. Then from (3), there are 2 possible cases - either

there are 8 men and 3 women or there are 3 men and 8 women.
If there are 8 men and 3 women, then there is 1 child. Then Statements (4) and (5) both are
false, which is not possible.
Hence, there are 3 men, 8 women and 6 children. Statement (4) is false.
The individual student should pay Rs. 50 for their journey.
Note that 3 persons are travelling between Bandra and Colaba.
The entire trip costs Rs. 300 to Mr. Subramanian. Hence, half of the trip costs Rs. 150.
For Andheri-Bandra-Andheri, only one person i.e. Mr. Subramaniam is travelling. Hence, he would
pay Rs. 150.
For Bandra-Colaba-Bandra, three persons i.e Mr. Subramaniam and two students, are travelling.
Hence, each student would pay Rs. 50.
42% houses do not have tubelight, bulb and fan.
Let's assume that there are 100 houses. Hence, there should be total 300 items i.e. 100
tubelights, 100 bulbs and 100 fans.
From the given data, we know that there is shortage of atleast (67+83+73) 223 items in every
100 houses.
Also, exactly 19 houses do not have just one item. It means that remaining 81 houses should
account for the shortage of remaining (223-19) 204 items. If those remaining 81 houses do not
have 2 items each, there would be a shortage of 162 items. But total of 204 items are short.
Hence, atleast (204-162) 42 houses do not have all 3 items - tubelight, bulb and fan.

Thus, 42% houses do not have tubelight, bulb and fan.