struct node* SortedMerge(struct node* a, struct node* b) { struct node* result = NULL; /* Base cases */ if (a == NULL) return(b); else if (b==NULL) return(a); /* Pick either a or b, and recur */ if (a->data <= b->data) { result = a; result->next = SortedMerge(a->next, b); } else { result = b; result->next = SortedMerge(a, b->next); } return(result); }
Jak zapisać tę funkcję iteracyjnie z użyciem pętli
Przypuśćmy że chcemy aby funkcja była typu void
a obecnie zwracana wartość przekazywana byłaby jako parametr