Python
Programming Exercises, Gently Explained
125
Special Cases and Gotchas
Keep in mind that while the list1 and list2 parameters must be sorted lists, they aren’t
required to be the same length.
If either of these list arguments to mergeTwoLists() isn’t sorted,
the function will return a
merged list that is also not in sorted order. For this exercise, however, we’ll
assume that
mergeTwoLists()
is always called with valid arguments.
Now try to write a solution based on the information in the previous sections. If you still have
trouble solving this exercise,
read the Solution Template section for additional hints.
Dostları ilə paylaş: