We consider an extended version of the activity selection problem discussed duri
ID: 2246720 • Letter: W
Question
We consider an extended version of the activity selection problem discussed during the lecture in week 3. We have a set of lectures {a_1, a_2, ..., a_n} and more than n lecture halls. Each lecture has a start and finish time and we cannot schedule lectures that overlap in the same lecture hall. We want to schedule all the lectures using as few lecture halls as possible. A set X of lectures is compatible in S if X Subsetequalto S and no two lectures in X overlap. As a starting point, the lecturer of COMP333 proposes the following recursive solution: range over the set of compatible subsets of lectures and for each such set compute an optimal for the remaining set of lectures. Formally: OptSchedule(S) = min_X compatible in S (1 + OptSchedule(S X)) We want to prove optimal sub-structure for this solution. Prove that an optimal solution for S includes optimal solutions for X (a compatible set of lectures).Explanation / Answer
ANS:-
Dear Student, Before Solving the Question Let me Define Optimal Solution
In computer technology, a hassle is stated to have most suitable substructure if an most effective answer may be built efficiently from best solutions of its subproblems. This belongings is used to decide the usefulness of dynamic programming and greedy algorithms for a hassle.
At the same time as dynamic programming may be efficiently carried out to a selection of optimization issues,many times the problem has an even extra truthful answer with the aid of the usage of a greedy method. Thismethod reduces solving multiple subproblems to discover the top of the line to truely solving one greedyone. Implementation of grasping algorithms is generally more straighforward and greater green, howeverproving a grasping approach produces ultimate effects calls for additional work.
------------The Greedy Method---------
general method
• maximum straightforward design approach
– most troubles have n inputs.
– Answer consists of a subset of inputs that satisfies a given constraint
– viable answer: Any subset that satisfies the constraint
– want to find a viable solution that maximizes or minimizes a given goal characteristic most appropriateanswer
• Used to decide a viable answer that could or might not be most useful
– At each factor make a choice this is domestically best and wish that it leads to a globally best answer
– ends in a effective technique for buying a solution that works well for a wide range of programs
The choose set of rules for process scheduling and its variation in working systems
– might not guarantee the excellent solution
• last aim is to discover a feasible solution that minimizes or maximizes an goal feature this answer isknown as
an most reliable solution
• Devise an set of rules that works in tiers subset paradigm
– do not forget the inputs in an order based totally on some selection system
Use a few optimization measure for choice system
– At every level take a look at an input to look whether or not it ends in an surest solution
– If the inclusion of enter into partial answer yields an infeasible solution discard the input otherwise addit to the partial solution.
– At every factor make the selection that appears quality at that factor
– might not continually result into highest quality solution
• Steps :-
1. decide most effective substructure of trouble
2. expand a recursive solution
3. display that if we increase a greedy preference then simplest one subproblem stays
4. show that it is usually safe to make the greedy desire five. broaden a recursive algorithm to put in force grasping approach
6. Convert the recursive algorithm to an iterative algorithm
• fashionable design standards
1. forged the optimization trouble as one wherein we make a choice and are left with one subproblem toremedy
2. prove that there may be usually an finest option to the authentic problem that makes the greedy desire,in order that thegrasping preference is always safe three. show most appropriate substructure by way of showing that, having made the grasping desire, what remains is a subproblem with the property that if we combine an most reliable strategy to the subproblem with the graspingpreference, we get an most reliable solution to the unique problem
• grasping-desire assets
– collect a globally most desirable solution which gives accurate solution.
Make anything choice seems highquality in the intervening time after which solve the closingsubproblem
preference made through grasping algorithm may also rely upon the alternatives made to this pointhowever can not depend upon destiny alternatives solutions to the subproblems
– must prove that a greedy desire at each step yields a globally most reliable answer
proof examines a globally top-rated technique to a few subproblem
– We may additionally preprocess the input to make grasping alternatives quickly
• premiere substructure
– A trouble famous most appropriate substructure if an most appropriate way to the problem consists ofinside it most fulfilling answersto subproblems
– anticipate that we arrived at a subproblem by way of making the grasping preference in the authenticproblem
– Argue that an most efficient strategy to the subproblem mixed with the greedy desire already made yields an most excellent option to the authentic problem
– The scheme implicitly uses induction on the subproblems to prove that makingthe greedy preference atevery step
produces an top rated solution.
Interest choice problem
• similar to procedure scheduling trouble in operating structures
• grasping algorithm correctly computes an ideal answer
• several competing activities require unique use of a common resource
• aim is to pick a hard and fast of maximum-length set of jointly compatible activities
– Set S of n proposed sports, requiring distinct use of a aid, consisting of a lecture corridor
S = {a1, a2, . . . , an}
– every pastime ai has a start time si and a end time fi
, such that zero si < fi <
hobby ai takes region in the c language [si, fi), if selected
– activities ai and aj are like minded if intervals [si , fi) and [sj , fj ) do now not overlap
well suited if si fj or sj fi
– pastime choice problem is to select a maximum-length subset of collectively like minded activities
– activities are assumed to be taken care of in monotonically growing order of finish time
f1 f2 f3 · · · fn1 fn..
----------premiere substructure of the interest-choice hassle---------------
– allow Sij be the set of sports that begin after ai finishes and before aj starts
– let Aij be the maximum set satisfying the limitations on Sij
– Aij includes a few activity ak
– by means of along with ak in optimal answer, we have to resolve two subproblems: find collectivelycompatible activities in units
Sik and Skj
– permit Aik = Aij Sik and Akj = Aij Skj
– Then, Aij = Aik {ak} Akj
– |Aij | = |Aik| + |Akj | + 1
– The most advantageous solution Aij have to also include most fulfilling answers to 2 subproblems Sik and Skj
|Aij | = zero if Sij =
maxakSij {|Aik| + |Akj | + 1}
Solution
I. permit S = {1, 2, . . . , n} be the set of activities. considering the fact that activities are in order through endtime. It implies that activity 1 has the earliest end time.
suppose, A is a subset of S is an ideal answer and permit activities in A are ordered by means of finish time.think, the primary activity in A is ok.
If k = 1, then A starts offevolved with grasping desire and we're finished
If k no longer=1 we want to expose that there is every other answer B that starts offevolved with greedypreference, pastime 1.
let B = A - {k} U {1}. due to the fact f1 =< fk, the activities in B are disjoint and since B has same number of activities as A, i.e., |A| = |B|, B is also optimal.
II. Once the greedy choice is made, the problem reduces to finding an optimal solution for the problem. If A is an optimal solution to the original problem S, then A` = A - {1} is an optimal solution to the activity-selection problem S` = {i in S: Si >= fi}.
Hence S includes set of Lecturers for X & set of Examples above.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.