S&P Capital IQ

  www.spcapitaliq.com
  www.spcapitaliq.com

Interview Question

Software Developer Interview New York, NY

Reverse a linked list

Tags:
linked list
Answer

Interview Answer

2 Answers

0

Google it

Interview Candidate on Feb 15, 2012
0

void reverse()
{
               node currentNode, nextNode,farNode;
               currentNode=first;
               nextNode=first.next;
               first.next=null;
               while(nextNode !=null)
              {
                         farNode=nextNode.next;
                         nextNode.next=currentNode;
                         currentNode=nextNode;
                         nextNode=farNode;
               }
     first = currentNode;

}

Sukanya on Mar 27, 2013

Add Answers or Comments

To comment on this, Sign In or Sign Up.