Recall & Review
beginner Click to reveal answer
What is the main goal when merging two sorted linked lists?
To create a new sorted linked list that contains all elements from both lists in ascending order.
beginner Click to reveal answer
In merging two sorted linked lists, why do we compare the current nodes of both lists?
To decide which node has the smaller value and should be added next to the merged list, maintaining sorted order.
intermediate Click to reveal answer
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 because they are already sorted.
intermediate Click to reveal answer
Why is a dummy node often used in the merge two sorted linked lists algorithm?
A dummy node simplifies the code by providing a starting point for the merged list, avoiding special cases for the head node.
beginner Click to reveal answer
What is the time complexity of merging two sorted linked lists with lengths m and n?
O(m + n) because each node from both lists is visited exactly once.
What is the first step in merging two sorted linked lists?
✗ Incorrect
We start by comparing the first nodes to decide which node to add first to the merged list.
What do you do when the current node of list1 is smaller than the current node of list2?
✗ Incorrect
Add the smaller node (list1's node) to keep the merged list sorted.
If list1 is empty but list2 still has nodes, what should you do?
✗ Incorrect
Since list2 is sorted, append its remaining nodes directly.
Why is a dummy node helpful in merging two sorted linked lists?
✗ Incorrect
A dummy node provides a fixed starting point, simplifying pointer handling.
What is the overall time complexity of merging two sorted linked lists?
✗ Incorrect
Each node is visited once, so the time is proportional to the sum of lengths.
Explain step-by-step how to merge two sorted linked lists into one sorted linked list.
Think about walking through both lists together and picking the smaller values.
You got /5 concepts.
Describe why using a dummy node simplifies the merging process of two sorted linked lists.
Imagine building a list without worrying about the first node.
You got /4 concepts.
