Starting from:

$39.99

CS 115 Lab 9-Searching and Sorting Solution


a) Download the class, Doctor, from Moodle.
b) Update the class to include the following:
a. Override the __lt__ method which determines if the id numbers of two doctors are in ascending order or not.

c) Create a script which includes the following:

• bubbleSort(): takes a list of Doctors as a parameter, and sorts the doctors according to their hospital name and specialty. The list should be sorted in place, no new lists should be created.
• binarySearch(): a recursive function that takes a list of Doctors, the id of a doctor to search and the starting and ending index of the list to be searched as parameters. The function should return the index of the doctor with the given id or -1 if the doctor does not exist in the list.
• readDoctors(): takes an empty list and a file name as parameters, and using the file data, creates Doctor objects and adds them to the list.

• Your script should do the following:
• Read the data from the doctors.txt into a list.
• Sort the list according to the id of the doctors.
• Input an id from the user and display the doctor with the given id (or appropriate message if doctor does not exist)
• Sort the list according to hospital and specialty and display the sorted list.

Sample Run 1:
Enter id of doctor to search: 36985
Doctor with id 36985
36985 Irem Basar Gastroenterology Ankara Hospital
Doctors by Hospital and Specialty:
36985 Irem Basar Gastroenterology Ankara Hospital
74532 Elif Som Optometry Ankara Hospital
87954 Jale Tunc ENT Bayindir
15487 Mehmet Keskin Optometry Hacettepe Hospital
12345 Ali Ayhan Cardiology Medicana
47896 Ayla Guner Cardiology Medicana
63215 Veysel Karakus Optometry Medicana
56987 Melis Koc ENT TOBB ETU

Sample Run 2:
Enter id of doctor to search: 54635
No such doctor
Doctors by Hospital and Specialty:
36985 Irem Basar Gastroenterology Ankara Hospital
74532 Elif Som Optometry Ankara Hospital
87954 Jale Tunc ENT Bayindir
15487 Mehmet Keskin Optometry Hacettepe Hospital
12345 Ali Ayhan Cardiology Medicana
47896 Ayla Guner Cardiology Medicana
63215 Veysel Karakus Optometry Medicana
56987 Melis Koc ENT TOBB ETU

More products