What is the main goal when merging two sorted linked lists?
To create a new linked list that contains all elements from both lists in sorted order without changing the original lists.
Click to reveal answer
beginner
In merging two sorted linked lists, why do we compare the head nodes of both lists?
Because the smallest element between the two lists will always be at one of the heads, so comparing helps pick the next smallest element to add to the merged list.
Click to reveal answer
intermediate
What happens when one linked list is fully traversed before the other during merging?
The remaining nodes of the other list are appended directly to the merged list since they are already sorted.
Click to reveal answer
intermediate
Show a simple Rust function signature for merging two sorted linked lists of integers.
Hint: Use Option for recursive linked list nodes in Rust [OK]
Common Mistakes:
Using direct ListNode type for next causes infinite size error
Using references without lifetimes causes borrow errors
Using Option<ListNode> misses boxing needed for recursion
3. Given two sorted linked lists where one list is empty and the other is 0 -> 2 -> 4 -> null, what is the merged list?
How does the merge function handle this edge case?