Programming Questions (50 marks) We received a list of reservations for people to be vaccinated for COVID-19. The list i
Posted: Fri May 20, 2022 5:53 pm
Question in java
Programming Questions (50 marks) We received a list of reservations for people to be vaccinated for COVID-19. The list includes the date for the reservation, the slot number within the day for the reservation, and the Medicare number for the person to be vaccinated. The date indicates on which date the vaccination is to be taken. The slot number is a positive integer where the day is divided into many slots and each slot could be mapped into a time of the day. The reservation date, slot and medicare are stored in three arrays: rDate,rslot and rMedicare. The three arrays are of the same size. The arrays' size N is the number of reservations. The list is stored based on the request for reservations. rDate[0] holds the date of the first reservation, rslot[0] holds the slot number for the first reservation, and rMedicare[0] holds the medicare number for the first person who made reservation to be vaccinated. rDate[1] holds the date of the second reservation, and rDate [[N-1] holds the date for the last reservation. . . We need to re-arrange the reservations based on the date and slot of the reservations. Your algorithm should rearrange the people's information in the array in the following manner: If the date of the reservation is already passed, then the reservation should be stored at the end of the array. If the date of the reservation is today or in the future, then it should be stored in the beginning of the array The reservations of today's date or future's date should be stored in ascending order by date, then by slot. Reservations of past date should be stored from the end of the array and backward where the oldest reservation date should be stored at the end of the array. In case we have future and past reservations, after re-arranging the array, the first position will hold the date, slot and medicare of the first person to be vaccinated. The last position will hold the date, slot and medicare of the first person who already got vaccinated. In case we do not have past reservations, after re-arranging the array, the first position will hold the date, slot and medicare of the first person to be vaccinated. The last position will hold the date, slot and medicare of the last person to be vaccinated. In case we just have past reservations, after re-arranging the array, the first position will hold the date, slot and medicare of the last person who got vaccinated. The last position will hold the date, slot and medicare of the first person who got vaccinated. If two reservations are on the same day and the same time slot, then the one who reserved first will be scheduled first. .
A sample of three input arrays of size 10 and their contents after rearrangements by the algorithm is shown below based on today's date is 2022-01-01: Input Output Index rDate rslot rMedicare rDate rslot rMedicare 0 2021-11-25 25 ccc11 2022-01-14 11 EEE99 1 2022-03-08 10 FFF22 2022-01-25 36 JJJ44 2 2021-12-02 7 DDD77 2022-02-01 10 GGG55 3 2022-02-01 15 HHH33 2022-02-01 15 HHH33 4 2021-12-02 3 KKK77 2022-02-01 15 BBB66 5 2021-12-03 40 AAA66 2022-03-08 10 FFF22 6 2022-01-25 36 JJJ44 2021-12-03 40 AAA66 7 2022-01-14 11 EEE99 2021-12-02 7 DDD77 8 2022-02-01 10 GGG55 2021-12-02 3 KKK77 9 2022-02-01 15 BBB66 2021-11-25 25 ccc11 a) In this programming assignment, you will design an algorithm in pseudo code), and implement in Java), four functions as follows: 1) rearrange Reservations: a recursive function that take as input three arrays rDate,rslot, rMedicare, current date and the number of reservations and returns the number of active reservations Assignment 1, COMP352 Summer 2022 Page 3 of 5 in addition to arranging the arrays as specified above. Active reservations are considered the reservations that their date is either today's date or future date, or reservations for people to vaccinated. 2) display Reservations: this function takes as input the three arrays r Date, rslot, rMedicare, and the number of future reservations and display all active reservations in an increasing order based on the date and slot. 3) displayPastReservations IncreasingOrder: a recursive function that takes as input the three arrays rDate, rslot and rMedicare and the number of past reservations and display the date, the slot, and the medicare of previous reservations in increasing order by date, then by slot. 4) display PastReservations DecreasingOrder: a recursive function that takes as input three arrays rDate, rslot and rMedicare and the number of past reservations and display the date, the slot, and the medicare of previous reservations in decreasing order by date, then by slot.
All your algorithms must handle possible special cases. For each implemented function you need to compare the runtime performance and measure the corresponding run times. You can use Java buil-in time function for this purpose. You can generate a file with random data and experiment your implementation against different size of reservations' list size N in (10, 100, 1000, 10000, 100000, 1000000). You should redirect the output of each set of test size to an out.txt file. You should write about your observations on the timing measurements in a separate text file. You are required to submit the fully commented Java source files, the compiled files, and the text files. For each implemented function: • Use the analysis from the course notes to determine a complexity function f(N). Your answer must be simple and concise. What is the time complexity of the function in terms of Big-o? .
Please Use recursive way to solve this Programming Questions (50 marks) We received a list of reservations for people to be vaccinated for COVID-19. The list includes the date for the reservation, the slot number within the day for the reservation, and the Medicare number for the person to be vaccinated. The date indicates on which date the vaccination is to be taken. The slot number is a positive integer where the day is divided into many slots and each slot could be mapped into a time of the day. The reservation date, slot and medicare are stored in three arrays: rDate,rslot and rMedicare. The three arrays are of the same size. The arrays' size N is the number of reservations. The list is stored based on the request for reservations. rDate[0] holds the date of the first reservation, rslot[0] holds the slot number for the first reservation, and rMedicare[0] holds the medicare number for the first person who made reservation to be vaccinated. rDate[1] holds the date of the second reservation, and rDate [[N-1] holds the date for the last reservation. . . We need to re-arrange the reservations based on the date and slot of the reservations. Your algorithm should rearrange the people's information in the array in the following manner: If the date of the reservation is already passed, then the reservation should be stored at the end of the array. If the date of the reservation is today or in the future, then it should be stored in the beginning of the array The reservations of today's date or future's date should be stored in ascending order by date, then by slot. Reservations of past date should be stored from the end of the array and backward where the oldest reservation date should be stored at the end of the array. In case we have future and past reservations, after re-arranging the array, the first position will hold the date, slot and medicare of the first person to be vaccinated. The last position will hold the date, slot and medicare of the first person who already got vaccinated. In case we do not have past reservations, after re-arranging the array, the first position will hold the date, slot and medicare of the first person to be vaccinated. The last position will hold the date, slot and medicare of the last person to be vaccinated. In case we just have past reservations, after re-arranging the array, the first position will hold the date, slot and medicare of the last person who got vaccinated. The last position will hold the date, slot and medicare of the first person who got vaccinated. If two reservations are on the same day and the same time slot, then the one who reserved first will be scheduled first. .
A sample of three input arrays of size 10 and their contents after rearrangements by the algorithm is shown below based on today's date is 2022-01-01: Input Output Index rDate rslot rMedicare rDate rslot rMedicare 0 2021-11-25 25 ccc11 2022-01-14 11 EEE99 1 2022-03-08 10 FFF22 2022-01-25 36 JJJ44 2 2021-12-02 7 DDD77 2022-02-01 10 GGG55 3 2022-02-01 15 HHH33 2022-02-01 15 HHH33 4 2021-12-02 3 KKK77 2022-02-01 15 BBB66 5 2021-12-03 40 AAA66 2022-03-08 10 FFF22 6 2022-01-25 36 JJJ44 2021-12-03 40 AAA66 7 2022-01-14 11 EEE99 2021-12-02 7 DDD77 8 2022-02-01 10 GGG55 2021-12-02 3 KKK77 9 2022-02-01 15 BBB66 2021-11-25 25 ccc11 a) In this programming assignment, you will design an algorithm in pseudo code), and implement in Java), four functions as follows: 1) rearrange Reservations: a recursive function that take as input three arrays rDate,rslot, rMedicare, current date and the number of reservations and returns the number of active reservations Assignment 1, COMP352 Summer 2022 Page 3 of 5 in addition to arranging the arrays as specified above. Active reservations are considered the reservations that their date is either today's date or future date, or reservations for people to vaccinated. 2) display Reservations: this function takes as input the three arrays r Date, rslot, rMedicare, and the number of future reservations and display all active reservations in an increasing order based on the date and slot. 3) displayPastReservations IncreasingOrder: a recursive function that takes as input the three arrays rDate, rslot and rMedicare and the number of past reservations and display the date, the slot, and the medicare of previous reservations in increasing order by date, then by slot. 4) display PastReservations DecreasingOrder: a recursive function that takes as input three arrays rDate, rslot and rMedicare and the number of past reservations and display the date, the slot, and the medicare of previous reservations in decreasing order by date, then by slot.
All your algorithms must handle possible special cases. For each implemented function you need to compare the runtime performance and measure the corresponding run times. You can use Java buil-in time function for this purpose. You can generate a file with random data and experiment your implementation against different size of reservations' list size N in (10, 100, 1000, 10000, 100000, 1000000). You should redirect the output of each set of test size to an out.txt file. You should write about your observations on the timing measurements in a separate text file. You are required to submit the fully commented Java source files, the compiled files, and the text files. For each implemented function: • Use the analysis from the course notes to determine a complexity function f(N). Your answer must be simple and concise. What is the time complexity of the function in terms of Big-o? .