We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Can someone explain to me how the previous node in A points to the new value of A after it has passed. Let me explain:
A: 1->3->NULL
....^
B: 2->4->6->NULL
....^
Initially we start at the head of the lists.
Since 1 < 2 it becomes
A: 1->3->NULL
..........^
B: 2->4->6->NULL
....^
Now, I understand that 2 points to 3 and 4 becomes the new head after that block of code, but when does 1 point to 2 since the pointer has already passed it? To me, it looks like 1 and 2 are pointing to 3.
Merge two sorted linked lists
You are viewing a single comment's thread. Return to all comments →
Can someone explain to me how the previous node in A points to the new value of A after it has passed. Let me explain:
A: 1->3->NULL
....^
B: 2->4->6->NULL
....^
Initially we start at the head of the lists. Since 1 < 2 it becomes
A: 1->3->NULL
..........^
B: 2->4->6->NULL
....^
Now, I understand that 2 points to 3 and 4 becomes the new head after that block of code, but when does 1 point to 2 since the pointer has already passed it? To me, it looks like 1 and 2 are pointing to 3.