Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Computer Science greedy algorithm problem. I will give a thumb up, thank you! (4

ID: 3753220 • Letter: C

Question

Computer Science greedy algorithm problem. I will give a thumb up, thank you!

(40 pts) An educational fair is held at Boulder High School field today from t0(9 am) to t 640 (5 pm). There are n schools Si,..., Sn attending the fair, and each school S, will attend during a time interval G, uil with 0-li ui-640, A school supply company wants to show its ad on a large screen television in the field several times during the day. The company has to make sure each school sees the ad but also wants to minimize the number of times the ad is shown. For example: school! [l, u 15,73 2[10,70 3[10,98) 4 [105, 160] 5 [130, 186] 6 90, 195) If the ad is shown at times t = 70 and t2-160, then all 6 schools will see the ad (a) Consider a greedy algorithm A that selects a time instance when the maximum number of schools are present simultaneously. The ad is scheduled at this time and the schools covered by this ad are then removed from further consideration The algorithm A is then applied recursively to the remaining schools. Give an example where this algorithm shows more ads than is necessary

Explanation / Answer

As there is no language constraint I wrote the solution in python. If you need solution in java please comment.

Python solution:

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote