Q:
Reverse a Singly Linked List
A:
public Node Reverse(Node head)
{
Node next;
Node current;
current = head;
Node Result = null;
while (current != null)
{
next = current.next;
current.next = result;
result = current;
current = next;
}
return (result);
}
Thursday, April 22, 2010
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment