Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Demystifying Databases A Hands On Guide For Database Management

Authors: Shiva Sukula

1st Edition

8170005345, 978-8170005346

More Books

Students also viewed these Databases questions

Question

What is an interrelation constraint? Give an example.

Answered: 1 week ago

Question

My opinions/suggestions are valued.

Answered: 1 week ago