Answer to Question #239114 in Algorithms for Zahid

Question #239114

Suppose you are a manager of an event management company. Your team is responsible for running various events. Each event, depending on its nature, runs for varied lengths. Your company policy is such that you charge a flat amount for each event your team is managing (irrespective of the duration a particular event). The size of the team that you are running is such that your team can manage to run one event at a particular time i.e. your company is unable to run multiple events at a particular time. More formally, if there are two events i and j, the events are mutually compatible (i.e. you can select both i andj) if s>f, ors,>fwhere s; and fi are the start and finish time of the event i. You are required to select events that your team is going to manage so that you can maximize the profit for your company. The following table shows some candidate events for your company to manage for a particular day. Find out which events would you select such that you can maximize the profit for your company.


1
Expert's answer
2021-09-19T08:05:54-0400

Let {tk}k=1,..,n set of all right ends of events in increasing order. For each time tk let we leave only one shortest event with this end.

Next we use dynamic programming method Let Fk be maximal number of mutually disjoint possible events with right ends less or equal to tk and t1k be left end of event with right end tk , qk=1 iff event (t1k,tk) should be used in optimal solution on subinterval [0,tk], also let k(t)=max{k: tk<t. or 0 if such tk does not exist. Then next formulas can be used

F0=0, F1=1,q1=1. Fk=max{Fk-1,1+ "F_{k(t_{1k})}" ),k=2,..,n and if Fk>Fk-1 qk=1 otherwise qk=0

Then values Fn,qn will present solutiom on on the entire interval [0,24]

Let for example set {(1,10),(5,17),(12,23)} is given. We have n=3 and t1=10,t2=17,t3=23. According to dynamic programming algorith we have:

F0=0, F1=1,q1=1. Next. F2=max{F1,Fk(5)+1)=max{1,F0+1)=max{1,1}=1.

F3=max{F2,Fk(12)+1)=max(1,F1+1)=max(1,2)=2>F2=> q3=1. Going back we find that q2=0,q1=1. Thus for chosen example problem is solved with q1=1,q2=0,q3=1 and should manage events (1,10) and (12,23) it is maximal set of mutually disjoint events.


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS