Skip to content

Commit 50f46be

Browse files
committed
compress linked_list_summary_en.png
1 parent e52ec7e commit 50f46be

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

en/linked_list/reverse_linked_list.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ Three cases when the recursion ceases:
138138
2. If given linked list has only one node, return that node.
139139
3. If given linked list has at least two nodes, pick out the head node and regard the following nodes as a sub-linked-list, swap them, then recurse that sub-linked-list.
140140

141-
Be careful when swapping the head node (refer as `nodeY`) and head of the sub-linked-list (refer as 'nodeX' ): First, swap `nodeY` and `nodeX`; Second, assign `null` to `nodeY->next` (or it would fall into infinite loop, and tail of result list won't point to `null`).
141+
Be careful when swapping the head node (refer as `nodeY`) and head of the sub-linked-list (refer as `nodeX` ): First, swap `nodeY` and `nodeX`; Second, assign `null` to `nodeY->next` (or it would fall into infinite loop, and tail of result list won't point to `null`).
142142

143143
### Python
144144

@@ -250,6 +250,10 @@ case1 and case2 can be combined.What case3 returns is head of reversed list, whi
250250

251251
### Complexity
252252

253+
The depth of recursion: ***O(n)***. Time Complexity: ***O(N)***. Space Complexity (without considering the recursion stack): ***O(1)***.
254+
255+
### Reference
256+
253257
- [全面分析再动手的习惯:链表的反转问题(递归和非递归方式) - 木棉和木槿 - 博客园](http://www.cnblogs.com/kubixuesheng/p/4394509.html)
254258
- [data structures - Reversing a linked list in Java, recursively - Stack Overflow](http://stackoverflow.com/questions/354875/reversing-a-linked-list-in-java-recursively)
255259
- [反转单向链表的四种实现(递归与非递归,C++) | 宁心勉学,慎思笃行](http://ceeji.net/blog/reserve-linked-list-cpp/)
-181 KB
Loading

0 commit comments

Comments
 (0)