Answered step by step
Verified Expert Solution
Question
1 Approved Answer
This is a greedy algorithm. Please do in java style pseudocode. Little Johnny is extremely fond of watching television. His parents are off for work
This is a greedy algorithm. Please do in java style pseudocode.
Little Johnny is extremely fond of watching television. His parents are off for work for the period [S, F), and he wants to make full use of this time by watching as much television as possible: in fact, he wants to watch TV non-stop the entire period [S, F). He has a list of his favorite n TV shows (on different channels), where the i-th show runs for the time period [sifi), so that the union of [si,fi) fully covers the entire time period IS, F) when his parents are away. Little Johnny doesn't mind switching in the middle of a show he is watching, but is very lazy to switch TV channels, so he wants to find the smallest set of TV shows that he can watch, and still stay occupied for the entire period [S, F). Design an efficient O(n logn) greedy algorithm to help Little Johny. Little Johnny is extremely fond of watching television. His parents are off for work for the period [S, F), and he wants to make full use of this time by watching as much television as possible: in fact, he wants to watch TV non-stop the entire period [S, F). He has a list of his favorite n TV shows (on different channels), where the i-th show runs for the time period [sifi), so that the union of [si,fi) fully covers the entire time period IS, F) when his parents are away. Little Johnny doesn't mind switching in the middle of a show he is watching, but is very lazy to switch TV channels, so he wants to find the smallest set of TV shows that he can watch, and still stay occupied for the entire period [S, F). Design an efficient O(n logn) greedy algorithm to help Little JohnyStep 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