Please solve this problem using C language Hacker Industries has a number of employees. The company assigns
Fantastic news! We've Found the answer you've been seeking!
Question:
Please solve this problem using C language
Transcribed Image Text:
Hacker Industries has a number of employees. The company assigns each employee a numeric evaluation score and stores these scores in a list. A manager is assembling a team for a new project and selects a number of employees from the list to create a team. He selects the team members in the following way: 1. During each selection, the manager chooses the employee with the highest score among either the first m available employees or the last m available employees in the list. The manager then removes the selected employee from the list and adds them to the team. That employee's score is stored to the team list. 2. If there are multiple employees with the same highest score among the first or last m available employees, the manager selects the employee whose score is at the lowest index in the list of scores. 3. If there are fewer than m available employees, then the manager picks the employee with the highest score from available employees. For example, consider a company with 5 employees, with score = [10, 20, 10, 15, 5] respectively. A team of two employees needs to be formed, and the value of m is given to be 1. • During the first selection, choose between the leftmost m elements: [10] and the rightmost m elements: [5]. The employee with score 10 is added to the team (10>5), and removed from the list. This makes score = [20, 10, 15, 5]. • During the second selection, employee with score 20 is added to the team (20 > 5), and removed from the list. This makes score = [10, 15, 5]. Hence, the total sum of the selected employees' scores is 10 + 20 = 30. Function Description Complete the function teamFormation in the editor below. The function must return the sum of the scores of all members selected for the team. teamFormation has the following parameter(s): score[score[0],....score[n-1]]: an array of scores for each employee. team: the number of team members required. m: the size of the array segments to select from. Constraints • 1 ≤ n ≤ 105 • 1 ≤ score[i] ≤ 10⁹ 1 ≤ team s n 1≤m≤n ▼ Input Format for Custom Testing Input from stdin will be processed as follows and passed to the function. The first line contains an integer n, the size of the array score. The next n lines each contain an element score[i] where 0 ≤ i 1 + #include ... 19 20 1 22 23 24 25 26 7 28 29 30 31 32 33 34 19 | 21 27 / + * Complete the 'team Formation' function below. } * The function is expected to return a LONG_INTEGER. function accepts following parameters: The 1. INTEGER_ARRAY score + + 2. INTEGER team + 3. INTEGER m +/ long team Formation(int score_count, int* score, int team, int m) { 34 int main() --- Hacker Industries has a number of employees. The company assigns each employee a numeric evaluation score and stores these scores in a list. A manager is assembling a team for a new project and selects a number of employees from the list to create a team. He selects the team members in the following way: 1. During each selection, the manager chooses the employee with the highest score among either the first m available employees or the last m available employees in the list. The manager then removes the selected employee from the list and adds them to the team. That employee's score is stored to the team list. 2. If there are multiple employees with the same highest score among the first or last m available employees, the manager selects the employee whose score is at the lowest index in the list of scores. 3. If there are fewer than m available employees, then the manager picks the employee with the highest score from available employees. For example, consider a company with 5 employees, with score = [10, 20, 10, 15, 5] respectively. A team of two employees needs to be formed, and the value of m is given to be 1. • During the first selection, choose between the leftmost m elements: [10] and the rightmost m elements: [5]. The employee with score 10 is added to the team (10>5), and removed from the list. This makes score = [20, 10, 15, 5]. • During the second selection, employee with score 20 is added to the team (20 > 5), and removed from the list. This makes score = [10, 15, 5]. Hence, the total sum of the selected employees' scores is 10 + 20 = 30. Function Description Complete the function teamFormation in the editor below. The function must return the sum of the scores of all members selected for the team. teamFormation has the following parameter(s): score[score[0],....score[n-1]]: an array of scores for each employee. team: the number of team members required. m: the size of the array segments to select from. Constraints • 1 ≤ n ≤ 105 • 1 ≤ score[i] ≤ 10⁹ 1 ≤ team s n 1≤m≤n ▼ Input Format for Custom Testing Input from stdin will be processed as follows and passed to the function. The first line contains an integer n, the size of the array score. The next n lines each contain an element score[i] where 0 ≤ i 1 + #include ... 19 20 1 22 23 24 25 26 7 28 29 30 31 32 33 34 19 | 21 27 / + * Complete the 'team Formation' function below. } * The function is expected to return a LONG_INTEGER. function accepts following parameters: The 1. INTEGER_ARRAY score + + 2. INTEGER team + 3. INTEGER m +/ long team Formation(int score_count, int* score, int team, int m) { 34 int main() ---
Expert Answer:
Answer rating: 100% (QA)
Code pasted below can be executed online at following URL httpswwwonlinegdbcomBJHQqZmU Stdin input u... View the full answer
Related Book For
Introductory Statistics for the Behavioral Sciences
ISBN: 978-0470907764
7th edition
Authors: Joan Welkowitz, Barry H. Cohen, R. Brooke Lea
Posted Date:
Students also viewed these programming questions
-
1. Accounts of Unnamed Company at December 31, 2019: 2$ Accounts Payable Accounts Receivable Accumulated Depreciation - PPE Allowance for Uncollectible Accounts Receivable Allowance for Uncollectible...
-
Solve this problem using the same methods and assumptions that you used for Exercise 1. a. Use the t value you computed to compare the students in the impossible to solve condition with those in the...
-
Refer to Problem 6-2. Solve this problem using the ERR method. Let = 12% per year. TABLE P6-2 Table for Problem 6-2 Capital investment Project life Annual revenue Annual expenses Market value...
-
Question. Consider the inverse demand function P=20-Q and the inverse supply function P=2+Q. Find (a) equilibrium price P* and Q*, (b) consumers surplus (CS), producers surplus (PS) and the total...
-
The income statement of Transparency Accounting Services Ltd. reported the following results of operations: Earnings from...
-
According to an article in the Wall Street Journal, Staples Inc., an office supply store, has found a new use for some of its roomy office-supply stores: make parts of them into offices. Because many...
-
Distracted Driving In a AAA Foundation for Traffic Safety survey, 21% of the respondents said that they recently texted or e-mailed while driving. Determine whether the given value is a statistic or...
-
On December 23, 2010, Miller Wholesalers ships merchandise to Michael Retailers with terms of FOB destination point. The merchandise arrives at Michaels warehouse on January 3, 2011. Required 1....
-
An American firm exports a product to Canada for CAD 2,500,000. They have a contract to receive payment from the importer in one year. The American firm is considering hedging the entire export...
-
The production manager at a factory manufacturing four types of light fittings (A, B, C and D) on an automated machine is fixing the schedule for the next week on this machine. HEIJUNKA SCHEDULING OF...
-
a. Compute the percentage change in nominal GDP, real GDP, and GDP deflator in 2020 and 2021 from the preceding year. For each year, identify the variable that does not change. Explain in words why...
-
How does a pivot table differ from a VLOOKUP function?
-
How can an organization better align its employees perceptions?
-
How can strategic groups be used to determine market competitors?
-
How can driving forces be used to envision the future?
-
What can be done to use SWOT analysis more effectively?
-
how to calculate a required 12% ROI of $7,000,000 over 10 years?
-
a. What is the cost of borrowing if Amarjit borrows $28 500 and repays it over a four-year period? b. How many shares of each stock would he get if he used the $28 500 and invested equally in all...
-
At Bigbrain University, the typical grade distribution is A, 15%; B, 25%; C, 45%; D, 10%; F, 5%. The grades given by two professors are shown here. For each one (separately), test the null hypothesis...
-
(a) Use your statistical package to compute the Pearson r between baseline and prequiz heart rates for all students; also, find the Pearson r between the pre- and postquiz heart rate measurements....
-
Repeat the previous exercise, except that this time there are 79 toddlers choosing among toys that come in a total of four different colors. The number of toddlers preferring each color is as...
-
A newspaper recently lowered its price from $5.00 to $3.00. As it did, the number of newspapers sold increased from 240,000 to 280,000. a. What was the newspapers elasticity of demand? b. Given that...
-
University of Richmond Professor Erik Craft analyzed the states pricing of vanity plates. He found that in California, where vanity plates cost an average of $28.75, the elasticity of demand was...
-
How is elasticity related to the revenue from a sales tax?
Study smarter with the SolutionInn App