educative.io

Educative

Why are we passing the node back?

Great course so far, I just wish that code portion on sorting a linked list using insertion sort code be better explained as an example:

if (!head || node.data <= head.data) {
node.next = head;  
return node;
}

why are we returning the node?

or why in the sortedInsertion function are we suddenly changing the params to head and node when we are passing in sorted and curr respectively?

Hi @Christian1, we are glad that you liked the course. Can you provide us the lesson link about which you are querying?