我在链表定义为一个节点:反向链接列表递归
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;
}
我该如何继续?我已经实现了迭代方法。
这功课吗?它看起来像功课。如果你想让人们帮你,那么你应该证明你至少试图自己解决问题。 –