Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. a. Write a C program to read the two times for each basket , perform the sort, then apply Johnsons rule, and finally print

1. a. Write a C program to read the two times for each basket, perform the sort, then apply Johnsons rule, and finally print details of the schedule. The first line of the input will be n, the number of baskets. Each of remaining n lines will contain a pair of non-negative integers for a baskets washing and drying times. The baskets will have indices from 0 to n - 1 to correspond to the order in which they are read.

b. The schedule should be printed with one output line per basket with the following details in this order: index, washing time, drying time, start time on the washer, start time on the dryer. Note that the schedule starts at time 0. If the dryer is ever idle between two baskets, you should print a line that indicates when the gap starts and finishes. After printing the entire schedule, you should print the makespan.

2. a. Suppose you have several baskets of laundry to wash and dry, but only one washer and one dryer. For each basket of laundry, you know the number of minutes to wash and the number of minutes to dry. To minimize the total time (the makespan), you could use https://en.wikipedia.org/wiki/Johnson%27s_rule to reorder the baskets

b. To implement Johnsons rule efficiently, it is convenient to first order the baskets with a sort that uses the smaller of the two times for each basket as the key. You may do the sort in any way you wish, but you are encouraged to use qsort() from the standard C library. The actual implementation of Johnsons rule should take linear time

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

Microsoft Office 365 For Beginners 2022 8 In 1

Authors: James Holler

1st Edition

B0B2WRC1RX, 979-8833565759

More Books

Students also viewed these Databases questions