我在鏈表定義爲一個節點:反向鏈接列表遞歸
typedef struct abc
{
int id;
struct abc *next;
}node;
我要反向鏈接列表recursively.I想過去的頭指針功能。我的功能定義如下:
node *reverseLinkedListRecursively(node *head)
{
node *current;
node *rest;
if(head == NULL)
return head;
current=head;
rest=head->next;
if(rest == NULL)
{
return rest;
}
reverseLinkedListRecursively(rest);
current->next->next=rest;
current->next=NULL;
return rest;
}
我該如何繼續?我已經實現了迭代方法。
這功課嗎?它看起來像功課。如果你想讓人們幫你,那麼你應該證明你至少試圖自己解決問題。 –