由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - How to implement "reverse a singly linked list" recursively
相关主题
C memory leak problem helprecurvion真的很难懂~~
好久没用C++了,想用静态变量写一个简单双向链表,一直报错树的前序遍历
how to reverse a HUGE list?stl 源代码疑问
swap every second node?请IT高手指点
Reversing a singly linked list问个算法题
reverse LL recursively这个题目能否半小时完成coding?
[合集] 问个递归的问题C++ 程序求助
Python: What does this mean?搜狐一题,寻解法
相关话题的讨论汇总
话题: curr话题: reverse话题: prev话题: singly话题: linked
进入Programming版参与讨论
1 (共1页)
c*********t
发帖数: 2921
1
The Iterative way can be simply done like this:
Reverse(ptr)
{
Prev=NULL;
Curr=ptr;
While (curr!=NULL)
{
Next= curr->next;
Curr->next = prev;
Prev = curr;
curr = next;
}
Return Prev;
}
Who can give a solution to reverse a singly linked list in a recursive
approach without using any global variable?
Thanks alot.
k****f
发帖数: 3794
2
都是local的,没有看见global

【在 c*********t 的大作中提到】
: The Iterative way can be simply done like this:
: Reverse(ptr)
: {
: Prev=NULL;
: Curr=ptr;
: While (curr!=NULL)
: {
: Next= curr->next;
: Curr->next = prev;
: Prev = curr;

1 (共1页)
进入Programming版参与讨论
相关主题
搜狐一题,寻解法Reversing a singly linked list
为什么这段程序scala慢java很多reverse LL recursively
请教大牛和小牛帮助菜鸟ML编程问题![合集] 问个递归的问题
guess what is this code for?Python: What does this mean?
C memory leak problem helprecurvion真的很难懂~~
好久没用C++了,想用静态变量写一个简单双向链表,一直报错树的前序遍历
how to reverse a HUGE list?stl 源代码疑问
swap every second node?请IT高手指点
相关话题的讨论汇总
话题: curr话题: reverse话题: prev话题: singly话题: linked