Question
Need answer in C. 2. Assume there are a special task sonsisting of n crucial steps and m workers such that each of them only
Need answer in C.
2. Assume there are a special task sonsisting of n crucial steps and m workers such that
each of them only knows how to deal with a subset of steps. The task switches hands from
one worker to another. Devise a greedy algorithm that takes an integer n together with m
subsets 1, , (each subset contains all the steps that the worker i can handle) as
input, and outputs an optimal scheduling that minimizes the number of switches, as an
array of n assignments together with an integer indicating the number of switches. All the
inputs given to the algorithm are assumed to be legitimate, i.e. the users are assumed to
provide only integers.
Assume = 5, = 3, and 1 = {1,2,5},2 = {1,3,5},3 = {2,3,4}. Possible schedulings will
be as follows : = [1,1,2,3,1] with 3 switches (from 1 to 2, from 2 to 3, from 3 to 1)
= [1,1,3,3,2] with 2 switches (from 1 to 3, from 3 to 2)
= [1,3,3,3,1] with 2 switches (from 1 to 3, from 3 to 1)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started