how to reverse a HUGE list?# Programming - 葵花宝典
s*e
1 楼
How can you print singly linked list in reverse order? (it's a huge list and
you cant use recursion) ?
大家有没有更好的方法 print “HUGE” list in reverse order? 谢谢!
BOOL ReverseList(node** pphead)
{
if(*pphead == NULL)
return FALSE;
node* pNode = NULL;
node* pTmp;
while(*pphead != NULL)
{
// tmp storage of header pointer
pTmp = (*pphead)->pNext;
// reverse
(*pphead)->pNext = pNode;
// pNode pointer moves one
you cant use recursion) ?
大家有没有更好的方法 print “HUGE” list in reverse order? 谢谢!
BOOL ReverseList(node** pphead)
{
if(*pphead == NULL)
return FALSE;
node* pNode = NULL;
node* pTmp;
while(*pphead != NULL)
{
// tmp storage of header pointer
pTmp = (*pphead)->pNext;
// reverse
(*pphead)->pNext = pNode;
// pNode pointer moves one