E.g: Single linked list is in order 1 -> 2 -> 3 -> 4
Expected
output : 4 -> 3 -> 2 -> 1
Any
answers?
*****************************************
Algo:
struct
Node {
Node *Next;
Node *Prev; // Only for Double Linked Lists
int
Data;
};
Node *RevSListB(Node *pCur)
{
Node *pRev =
NULL;
while (pCur)
{
Node *pNext = pCur->Next;
pCur->Next =
pRev;
pRev = pCur;
pCur = pNext;
}
return pRev;
}
Feel
free to provide any other answers.
No comments:
Post a Comment