In the process of reading any questions, welcome to communicate together
Email: [email protected]    
QQ:1494713801
Problem:
Give a one-way list and reverse it from beginning to end. For example, C->d, a, b  , A, B, C , a . 
Analysis:
Suppose that  the structure of each node is:
Class Node {char value; Node Next;}
The non-recursive code is as follows:
1. void reverse (struct Node **list)
2. {
3. struct Node *currentp = *list;
4. struct Node *pleft = NULL;
5. struct Node *pright = NULL;
6.
7.
8. while (CURRENTP! = NULL) {
9. Pright = currentp->next;
Ten. Currentp->next = Pleft;
Pleft = CURRENTP;
CURRENTP = Pright;
13.}
*list = Pleft;
15.}
The recursive way code is as follows:
1. struct node* recursive_reverse (struct Node *list)
2. {
3. struct Node *head = list;
4. struct Node *p = r_reverse (list);
5. Head->next = NULL;
6. return p;
7.}
8.
9. struct node *r_reverse (struct node *list)
10. {
One. if (NULL = = List | | NULL = = List->next)
A. return list;
struct Node *p = R_reverse (List->next);
List->next->next = list;
. return p;
16.}
The recursive method is actually very clever, it uses recursion to go to the end of the list, and then update each node's next value (the second sentence of the code). In the above code, the value of reverserest does not change for the last node of the linked list, so, after inversion, we can get the new linked list head.
Single linked list adjacent elements transpose (non-recursive)
1. struct node* recursive_reverse (struct Node *list)
2. {
3. struct Node *head = list;
4. struct Node *p = r_reverse (list);
5. Head->next = NULL;
6. return p;
7.}
8.
9. struct node *r_reverse (struct node *list)
10. {
One. if (NULL = = List | | NULL = = List->next)
A. return list;
struct Node *p = R_reverse (List->next);
List->next->next = list;
. return p;
16.}
4 single-linked list adjacent elements transpose (recursive)
1. struct node * recursive_partial_reverse (struct node *list)
2. {
3. if (NULL = = List | | NULL = = List->next)
4. return list;
5. struct Node *p = list->next;
6. struct Node *node = Recursive_partial_reverse (List->next->next);
7. List->next->next = list;
8. list->next = node;
9. return p;
10.}
Reference Links:
http://blog.csdn.net/skylinesky/article/details/760694
"Algorithmic problems" using recursion and non-recursion to implement the transpose of a unidirectional list