I asked a question last night on how to sort() a double linked list in C++.
I managed to get it to work, but now I’d like to merge two lists, but I can’t
get it to work. I don’t have much code, I’m sorry. Everything I tried
absolutely made no sense. I’d just like if someone could give me some hints on
where to start, or on how to do this, with the information I’m going to
provide.
This is what I had in the beginning:
void next() { if (curr != tail) curr = curr->next; }
I believe I only need these.
I looked at some exemples online, but it doesn’t make any sense to me. It
seems so different than what I have right now. Apparently it should be A LOT
easier than doing a sort function, which I had barely any trouble doing.
Any explanation/hints would be greatly appreciated! And I’m sorry once again
for the lack of code, I just don’t know where to start.
You can actually do this in multiple ways
It looks like you’re trying to do no. 3 here.
In which case, you can just
This would however destruct the original list. I think it’s better to copy them to a third list.