You have a complex project involving m independent tasks. Since the tasks can be performed in parallel, the time to complete the project will be the maximum time taken by any task. You’d like to hire one of k companies to do the whole project, and you’re given a 2- dimensional list x with k rows and m columns, where x[i][j] is the amount of time company i would take to complete task j. Write a Python function hire(x) to help you decide which company to hire; it should return a pair (i, j) where i is the index of the company that will finish the project quickest, and j is the index of the task that will take them the longest (the “bottleneck”). The running time should be O(km), i.e., linear as a function of the total number of entries. For example, hire([[1, 4], [3, 2]]) should return (1, 0). Do not use Python’s built-in min or max functions.
Thanks for posting the question, here is the code in Python to find the index of the company that will finish the task first and the index of the company that will take the maximum time.
Here is the code and the screenshot
_____________________________________________________________________________________________
def hire(x):
fastest_company_index=0
longest_company_index=0
fastest_time=x[0][1]
longest_time=x[0][1]
for index in range(len(x)):
entry = x[index]
if fastest_time > entry[1]:
fastest_time=entry[1]
fastest_company_index=index
if longest_time<entry[1]:
longest_time=entry[1]
longest_company_index=index
return fastest_company_index,longest_company_index
print(hire([[1,4],[3,2]]))
________________________________________________________________________________________________
![|芔CookieCalculator.py def hire (x) Eastest_corpany index-0 longest company index-0 astest_tire-x[0j [i] longest_tire-xlo] 1 for index in range (ien (x)) entryx[index] if fastest time > entry]: 10 Eestest tine-entry[i] astest_company index-index 12 13 14 L5 L6 17 18 19 20 if longest_timecentry: longest tine-entryi] longest_company index-index return fastest_company_index, longest_company index print 《h1re {[[1,4], [3,2]])) hire CookieCalculator C:UerUser PycharmProjects Cheggvenv Scripts python.exe C:Users/User/PycharmProjectsChegg.idea/CookieCalculator.py for index in rangellen())if fastest time> entryl1] Run: Process finished cxit code 0 IDE and Plugin Updates PyCharm is ready to update. 兼S; Debug :-S: TODO Terminal Python Console IDE and Plugin Updates: PyCharm is ready to update. (15 minutes age) 4: Run 12:40 CRLF: UTF-8:](http://img.homeworklib.com/questions/b747ebb0-9af0-11eb-99d4-e94d25d41c17.png?x-oss-process=image/resize,w_560)
thank you so much : )
You have a complex project involving m independent tasks. Since the tasks can be performed in...
Assume that for this project to be completed, five independent tasks must be completed. These tasks are proceeding in parallel by five different subcontractors. To keep it simple, let's assume that each task takes between 1 and 5 months to complete (uniformly distributed, i.e. equally likely to take any amount of time between 1 and 5 months). So, the mean time to complete each task is 3 months and the probability of any given task taking 3 months or longer...
Question #1: Some of the tasks in this project can be done in
parallel. Prepare a diagram showing the required network of tasks
and define the critical path. What is the length of the project
without crashing? Do not just answer, but show the whole
process.
Question #2: If the critical path is longer than 29 days, what
is the least additional amounting that Dr. Watage can spend and
still achieve this schedule objective (29 days)? Do not just
answer,...
Help due in a few hours I need to clean this up can you help me
clean up this code to accomplish the same task but with fewer
lines/ more elegantly.
Thank you!
My code for the function is below:
int is_valid_board(int board[9][9]) {
int array[10];
int array_box[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
int i, j, k, x, y; //rows=i, columns =j
for (i=0; i<9; i++) {
//Reset test array
for (x = 0; x...
Please Implement this code using Java Eclipse.
CIS 1068 Assignment 8 Warm Up with Objects Due: Wednesday, March 25 70 points (+ up to 15 extra credit) The purpose of this assignment is to give you practice implementing your own classes. It also provides extra practice with arrays. Task Implement a class Task, which is used to represent a job that should be done. It should contain the following private fields: .name text description of what job should be done...
-can you change the program that I attached to make 3 file
songmain.cpp , song.cpp , and song.h
-I attached my program and the example out put.
-Must use Cstring not string
-Use strcpy
- use strcpy when you use Cstring: instead of this->name=name
.... use strcpy ( this->name, name)
- the readdata, printalltasks, printtasksindaterange,
complitetasks, addtasks must be in the Taskmain.cpp
- I also attached some requirements below as a picture
#include <iostream>
#include <iomanip>
#include <cstring>
#include <fstream>...
This is due in a few hours I don't know if I did this correctly
can you double check my code to see if my return statements are
fine and I follow the instructions accurately. Thank you!!!
Modify my code if anything return statement seems misplaced or
inaccurately called.
Here is my code:
int write_sudoku_board(const char file_name[ ], int board[9][9])
{
int number;
int i,j;
int a = 9;
FILE* fp = fopen("sudoku.txt", "w");
int count = 0;
for(i =...
Write a paper on: Assume that you have been assigned as the project manager for a project. Explain how you would go about estimating project tasks and project duration. Describe how you would apply estimating, scheduling, work breakdown structures, project plans, safety, change control, project baselines and the concept of a critical path, which you would choose for your project, and rational why. Also explain who you would involve in the estimation process and when you would involve them. Keep...
you will analyse two algorithms for finding the median of an array of integers. You will compare both algorithms in terms of timing, and hopefully design a hybrid algorithm that uses both, depending on input size. You will write a report describing your experiments and results. the following Java program implements two algorithms for finding the median of an array of integers. The first uses merge sort, and the other implements the recursive linear time selection algorithm, the task is...
PLEASE CODE IN C++ AND MAKE IT COPYABLE! In this project, you will design and implement an algorithm to determine the next greater element of an element in an array in Θ(n) time, where 'n' is the number of elements in the array. You could use the Stack ADT for this purpose. The next greater element (NGE) for an element at index i in an array A is the element that occurs at index j (i < j) such that...
I
need help writing this code in C++
Proj11.cpp is provided as well as the randomdata.txt
thank you in advance!
Objectives: The main objectives of this project is to introduce you to recursion, and test your ability to work with some STL functionalities. A review of your knowledge on working with templates, dynamic data structures, as well as manipulating dynamic memory, classes, pointers and iostream to all extents, is also included. Description: For the entirety of this project, you will...