Reverse list
Unidirectional linear inversion table linklist
N the list before reversing done it many times, because there are many reverse list approach, the idea is not the same each time, once to spend time thinking think, believe it will error, the list of today's processes look picture , credited a method, a way to do it in the end.
List Reverse(List L){
List p, q;
p = L->Next;
L->Next = NULL;// 先将头链表next指针置空
// q要始终指向L的next,做为已排好序列的第一个元素
// p要指向待排序列的第一个元素,p为空则序列全部反转
while(p){
q = p;
p = q->Next;
q->Next = L->Next;
L->Next = q;
}
return L;
}
Map and thinking to understand that time will naturally write