Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Code must be written in C Language/ UBUNTU environment. To get full credit for each question, you need to provide a brief explanation of your
Code must be written in C Language/ UBUNTU environment.
To get full credit for each question, you need to provide a brief explanation of your codes and the efficiency analysis with comments. Also, you need to provide the proof for the correctness of the algorithm with comments.
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 AJ, ..., Am (each subset A 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 n = 5, m = 3, and A2 = {1,2,5}, A2 = {1,3,5}, Az = {2,3,4}. Possible schedulings will be as follows : X = [1,1,2,3,1] with 3 switches (from 1 to 2, from 2 to 3, from 3 to 1) X = [1,1,3,3,2] with 2 switches (from 1 to 3, from 3 to 2) X = [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