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]]))
________________________________________________________________________________________________
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,...
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...
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...
-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 =...
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...
Question 9 Below is the time phased baseline budget for a project and a table showing the progress as of End of Period 7. 2 Baseline PV Total Task Time Period PV 0 1 3 5 6 7 8 10 11 A 30 15 15 40 20 20 с 80 10 10 10 10 20 20 D 30 5 5 5 5 10 E 20 5 5 5 5 F 40 10 20 5 5 10 5 5 PV by...