~ Using Java, please manipulate the following code in order to have it output according to Earliest Start Time and NOT E
Posted: Sun Jul 03, 2022 12:01 pm
~ Using Java, please manipulate the followingcode in order to have it output according to Earliest StartTime and NOT Earliest FinishingTime.
----------------------------------
----------------------------------
*** CONSIDER THIS ***
Each interval is defined by [a,b] where a = start time and b = end time [1,100], [2,3], [4,5], [6,7], [8,9], [10,11] Now if we order these intervals from earliest start time to latest start time then we get: [1,100] [2,3] [4,5] [6,7] [8,9] [10,11] So they get added in the priority queue with [1,100] on top. Now from the priority queue we remove the first interval that is [1,100], it gets added to the answer set S. Now from the priority queue we remove [2,3] but it cannot be added in the set S as it contains [1,100] and [1,100] and [2,3] are overlapping. Similarly [4,5], [6,7], [8,9], [10,11] are also overalapping with [1,100] so none of them get added to the answer set S. So from this algorithm we get the answer set S = {[1,100]}
----------------------------------
----------------------------------
*** CONSIDER THIS ***
Each interval is defined by [a,b] where a = start time and b = end time [1,100], [2,3], [4,5], [6,7], [8,9], [10,11] Now if we order these intervals from earliest start time to latest start time then we get: [1,100] [2,3] [4,5] [6,7] [8,9] [10,11] So they get added in the priority queue with [1,100] on top. Now from the priority queue we remove the first interval that is [1,100], it gets added to the answer set S. Now from the priority queue we remove [2,3] but it cannot be added in the set S as it contains [1,100] and [1,100] and [2,3] are overlapping. Similarly [4,5], [6,7], [8,9], [10,11] are also overalapping with [1,100] so none of them get added to the answer set S. So from this algorithm we get the answer set S = {[1,100]}