Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Using JAVA: (1) Clean up Friend List After getting the best student award, Jenny has become very popular in her university. Her Facebook profile is
Using JAVA:
(1) Clean up Friend List After getting the best student award, Jenny has become very popular in her university. Her Facebook profile is full of friend requests. Being a nice person, she has accepted all the friend requests. Jenny's best friend Phoebe is annoyed as Jenny is giving those newly added friends a lot of time. Phoebe asked Jenny to delete those people from the list as she hardly knows them To avoid problem in their friendship Jenny decides to remove some of the friends from her friend list. Since she can see the number of mutual friends she uses the following rule to delete some friends while keeping few She bucketize the friends based on the number of mutual friends into K buckets, where K is the number of friends she wants to keep (she will keep at most K friends, she might keep less than K). For each bucket, she put the friends in a circle in sorted order based on number of mutual friends (least to most), if multiple friends have same number of mutual friends, she put them in the order as they appear in the input. Counting begins at a friend having least number of mutual friends in the circle and proceeds around the circle in clockwise direction. After K-1 number of friends are skipped, the next person (Kh) is deleted. The procedure is repeated with the remaining friends, starting with the next person, going in the same direction and skipping K-1 number of people, until only one friends remains, and she keeps that friend in the list. How to bucketize? - Find minimum (minMF) and maximum (maxMF) number of mutual friends Divide the range [minMF, maxMF] into K equal sized buckets. Only the last bucket can have range smaller or larger than the other buckets. Put a friend in a bucket if the number of mutual friends falls in the range of that bucket. For example: [minMF, maxMF [2, 11] and K 3, the range of 3 buckets are [2,4], [5,7], [8,11] For some test case, there might be 1 or more buckets which are empty. If there are E empty buckets then Jenny keeps K - E friends. If a bucket gets only one friend then Jenny just keeps that friend Input Format: Read input from a file "in1.txt". The first line contains T number of test cases. The first line of each test case consists of two space separated integers N and K, denoting the number of newly added friends and the number of friends Jenny wants to keep respectively. The second line consists of N strings representing the names of N newly added friends. The next line consists of integers representing the number of mutual friends of each of the above people with Jenny Output Format: Write output in console. Print the names of those K friends whom Jenny wants keep in her friend list in the order as they appear in the input. Sample Input 10 3 abcdefghij 10245732911 6 Sample Output a bjStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started