Question: Problem 2 Shortest building time (15 points) Imagine you are the main contractor building a large skyscraper. You are promised a huge bonus if you

 Problem 2 Shortest building time (15 points) Imagine you are the

Problem 2 Shortest building time (15 points) Imagine you are the main contractor building a large skyscraper. You are promised a huge bonus if you can finish the job fast. Obviously, there are some constraints; you cannot install windows until you have built the walls. However, you can easily install windows and doors at the same time, while also painting the walls. You want to get an estimate on how long it will take you to build the skyscraper. (You may assume that each task is taking exactly one day to finish.) You have enough resources to perform independent tasks simultaneously. (a) (2 points) Find how to represent this problem by using a directed graph. Make sure to give a precise description of how nodes, edges and directions are assigned. (b) (5 points) Assume you are given a directed graph in an adjacency list format. Suppose you are removing nodes and the adjacent edges one at a time (in random order). Find an O(m + n) algorithm to keep track of the current indegree of each node. (c) (8 points) Find an efficient algorithm that returns the order in which tasks should be executed. Your algorithm will return an array A of lists, such that the list A[i] consists of the tasks that can be executed on day i. Hint: In each iteration find all the nodes with zero indegree and remove. To do this efficiently you may find the algorithm from part (b) useful.] Problem 2 Shortest building time (15 points) Imagine you are the main contractor building a large skyscraper. You are promised a huge bonus if you can finish the job fast. Obviously, there are some constraints; you cannot install windows until you have built the walls. However, you can easily install windows and doors at the same time, while also painting the walls. You want to get an estimate on how long it will take you to build the skyscraper. (You may assume that each task is taking exactly one day to finish.) You have enough resources to perform independent tasks simultaneously. (a) (2 points) Find how to represent this problem by using a directed graph. Make sure to give a precise description of how nodes, edges and directions are assigned. (b) (5 points) Assume you are given a directed graph in an adjacency list format. Suppose you are removing nodes and the adjacent edges one at a time (in random order). Find an O(m + n) algorithm to keep track of the current indegree of each node. (c) (8 points) Find an efficient algorithm that returns the order in which tasks should be executed. Your algorithm will return an array A of lists, such that the list A[i] consists of the tasks that can be executed on day i. Hint: In each iteration find all the nodes with zero indegree and remove. To do this efficiently you may find the algorithm from part (b) useful.]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!