I don't understand the reversal of the list of a node l in a binomial heap:
Node* reverseList(Node* l) {
//return reverseNode(l);
if(l->sibling)
{
return reverseList(l->sibling);
l->sibling->sibling = l;
}
}
What does this mean? :
l->sibling->sibling = l;
The parent?

A
returnstatement ends the execution of the function, so you are asking about dead code.I would expect the function to actually be like this:
To visualise this, let an example linked list consist of three nodes:
When the function is called, we get into the
ifand make a recursive call. That new (second) execution context has its own local variables, and to distinguish them, I will add an accent to their names. So we have anotherl'variable:Also that function's execution will make a recursive call:
The latest (third) execution of the function gets
l'->siblingas argument and will assign that to its own local variablel". It will find thatl"->siblingisNULL, and so it just returns the same pointer without making any alteration. At this moment the lifetime of the variablel"ends. The caller assigns the returned value to a localhead'variable -- again the accent to make clear this happens in the second execution context:Now we get to the statement:
l'->sibling->sibling = l'. That means an assignment is made to thesiblingmember of the last node, and so we get:Then we execute
l'->sibling = NULL:Then we execute
return head'. The variables of the second execution context end their lives (no more accents). The first execution context will assign the returned pointer to its ownheadvariable:Now we get to the statement:
l->sibling->sibling = l. That means an assignment is made to thesiblingmember of the middle node, and so we get:We execute
l->sibling = NULL:And finally, we return
head. The local variables end their lifetimes, and so only the returned pointer is relevant:You can see that the returned pointer is indeed referencing the reversed list.