Write a program that merges two ordered list objects of integers into a single o
ID: 3627875 • Letter: W
Question
Write a program that merges two ordered list objects of integers into asingle ordered list object of integers. Function merge should receive
references to each of the list objects to be merged and reference to a list
object into which the merged elements will be placed.
Explanation / Answer
function merge(left,right) var list result while 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) end while if length(left) > 0 append left to result else append right to result return result hope this helps
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.