Write pseudo-code to solve the problem using MapReduce and explain how it works.
Each line in the file lists a person’s ID, name, age, and the number of friends he or she has. For example line 1 indicates that the person has ID of 0, his name is Will, his age is 33, and he has 385 friends. Given the file, find out the average number of friends by age.
0,Will,33,385
1,Jean-Luc,26,2
2,Hugh,55,221
3,Deanna,40,465
4,Quark,68,21
5,Weyoun,59,318
Pseudo code:
step1: read the file with read mode
step2: read each line in the file and split with comma(,)
step3: then take 2 and 3 index data make sum and increment cnt
step4: finally age/cnt and number/cnt
step5:finally print the average age and average friends
step6:colse the file
Get Answers For Free
Most questions answered within 1 hours.