http://www.geeksforgeeks.org/write-a-function-to-reverse-the-nodes-of-a-linked-list/
看到這個遞歸程序(C語言)扭轉單向鏈表。
void recursiveReverse(struct node** head_ref){
struct node* first;
struct node* rest;
/* empty list */
if (*head_ref == NULL)
return;
/* suppose first = {1, 2, 3}, rest = {2, 3} */
first = *head_ref;
rest = first->next;
/* List has only one node */
if (rest == NULL)
return;
/* reverse the rest list and put the first element at the end */
recursiveReverse(&rest);
first->next->next = first;
/* tricky step -- see the diagram */
first->next = NULL;
/* fix the head pointer */
*head_ref = rest;}
在此步驟中該程序,
/* reverse the rest list and put the first element at the end */
recursiveReverse(&rest);
first->next->next = first;
我可以寫 「休息 - >下一=第一;」 代替 「一線>下一步 - >下一=第一;」?
或者是否有寫「first-> next-> next = first;」的意義?
http://stackoverflow.com/questions/37725393/reverse-linked-list-recursively – BLUEPIXY