Moooni
August 15th, 2008, 05:24 PM
Thanks.
|
Click to See Complete Forum and Search --> : singly linked list swap pairs... I've hit a brick wall Moooni August 15th, 2008, 05:24 PM Thanks. darwen August 16th, 2008, 07:27 AM The algorithm is : If N is node to swap and N->Next is next in list then to swap N and N->Next If N is end of list (i.e. N->Next == null) Then Error If N is Head of list then Head of list = N->Next N->Next = Head of list->Next Head of list->Next = N Else Find Previous node to N. Previous node To N->Next = N->Next N->Next = Previous node to N->Next Previous Node to N->Next = N Darwen. codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |