The Apgar Medical group keeps a patient file for each doctor in the office. Each
ID: 3567275 • Letter: T
Question
The Apgar Medical group keeps a patient file for each doctor in the office. Each record contains the patients first and last name, home addreses, and birth year. The records are sorted in ascending birth year order. Two doctors, Dr. Best and Dr. Cushing, have formed a partner ship. Design the logic that produces a merged list of their patients in ascending order by birth year.
In Pseudocode ONLY!!!
Explanation / Answer
function merge(left,right) var list result while length(left) > 0 or length(right) > 0 if length(left) > 0 and length(right) > 0 if first(left) ? first(right) append first(left) to result left = rest(left) else append first(right) to result right = rest(right) else if length(left) > 0 append first(left) to result left = rest(left) else if length(right) > 0 append first(right) to result right = rest(right) end while return result
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.