*Language must be Java* Overview: Recall the IntervalScheduling problem: you are given a set of intervals and asked to f

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

*Language must be Java* Overview: Recall the IntervalScheduling problem: you are given a set of intervals and asked to f

Post by answerhappygod »

*Language must be Java*
Overview: Recall the IntervalScheduling problem: you are given aset of intervals and asked to find the largest cardinality subsetthat has no overlapping intervals. We found that theEarliestStartingTime algorithm was not optimal by finding aninstance where it did not get the best possible solution.Occassion- ally, you will want to test an algorithm on a problem tofind an instance where it does not get the optimal solution.
Details: The input will come from a file called input.txt whichwill be placed in the same directory as your java file. The firstline of the file will have a single integer value N which will bethe number of intervals. The next N lines will be the intervalsrepresented by si and fi seperated by whitespace. Your programshould output a single integer which is the number ofnon-overlapping intervals found by the EarliestFinishingTimealgorithm. It is likely that the number of intervals found will notbe the optimal solution. See the sample input below forexamples.
Sample execution:
If input.txt contains
8
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
then the output should be 1
If input.txt contains 5
1 10
2 3
4 5
6 7
8 9 then the output should be 1
Thank you!
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply