1) Give the algorithm (step by step) and explain/justify why it takes about ????2 time complexity. 2)...
Question:
1) Give the algorithm (step by step) and explain/justify why it takes about ????2 time complexity.
2) Write a program called “contactTracing.java”, which implements the algorithm in 1.
a) Ask the user to input the number of babies in the creche
b) Followed by arrival and departure times (separated by “,”) for each baby
c) Store these data into a data structure
d) Apply algorithm 1 on the data structure and determine the pairs
Sample Input
How many pairs of baby: 5
Give the times of arrival (i) and departure (j), e.g.: 2,4
2,4
Give the times of arrival (i) and departure (j), e.g.: 2,4
3,6
Give the times of arrival (i) and departure (j), e.g.: 2,4
8,9
Give the times of arrival (i) and departure (j), e.g.: 2,4
10,11
Give the times of arrival (i) and departure (j), e.g.: 2,4
7,11
Sample Output
The distinct pairs of babies who are at the crèche simultaneously are
(1, 2) (3, 5) (4, 5)