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...
-
For each of the following reactions, indicate whether the reaction would work well, poorly, or not at all. Formulate alternative products, if appropriate. (a) (b) (c) (d) (e) (f) (g) (h) (i) (j) (k)...
-
On January 1, 2017, Taco Taqueria, a Mexican restaurant, purchased equipment for $12,000 cash. Taco Taqueria estimates that the equipment will last five years (useful life). The restaurant expects to...
-
In a contract dispute between a US company and a Canadian company, the contract itself referred to provisions of the Uniform Commercial Code. Do these references alone preempt the contract from being...
-
You are auditing general cash for the Pittsburgh Supply Company for the fiscal year ended July 31, 2011. The client has not prepared the July 31 bank reconciliation. After a brief discussion with the...
-
1. Solve the following using convolution and correlation a. Let I={0, 0, 1, 0, 0} & Let k (mask) = {3, 2, 8} 3 3 b. Let I = & Let k (mask) = 3 3 1 24 3 4
-
Albert owns 100% of A Corporation, Betty is the sole proprietor of B Company, and Cai is the sole proprietor of C Company. Each business generated $500,000 of taxable income and before-tax cash flow....
-
Your company is a distributor of surfboards located in Vancouver, BC. The company does not collect sales tax as all of its customers are resellers. Leave Industry text box blank. You began business...
-
Calculate two NPVs for the project at two different costs of capital. One NPV must be negative, and another one is positive. 2. Using the following formula to find the IRR: IRR = L + where: L =...
-
a) How many bits would be required if one wishes to code each of the seven days of a week with a binary number. b) How many bits would be required if one wishes to code all upper-case letters plus...
-
A cube made of aluminum 2 4 x1o -6 has sides of 5 . 0 0 0 0 cm , and it is subjected to a temperature change of + 5 0 0 C ? 1 . What will this temperature change be on the Kelvin scale? 2 . What is...
-
BCD Fund Ltd("Fund") was launched on 09/01/2020 and has two types of investors in the Fund, Class 2020 investors who pay management fees at 2% of commitment per annum and the new class 2021 where...
-
On an imaginary temperature scale, 1 0 0 0 C corresponds to 2 5 6 degrees and 0 0 C to 1 1 degrees. Convert 1 3 3 degrees on this scale to 0 C .
-
Find the error for the proposed solution. Then correct the proposed solution. 8x+1.5=3x+0.6 5x=0.9 (5x)/(5)=(0.9)/(5) x=0.18
-
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...
-
The required rate of return is 12%, and the expected rate of inflation over the life of the project is forecast to remain steady at 3%. Should you invest in this project?
-
For your answer to Problem 3.11, construct an argument as to why this selection process is useful for deciding which project is best. Now, construct a counterargument to criticize this choice. In...
-
Scoring Model. Suppose the information in Problem 3.13 was supplemented by importance weights for each of the four assessment criteria, where 1 = low importance and 4 = high importance: Assume, too,...
Study smarter with the SolutionInn App