|
-
August 15th, 2008, 05:24 PM
#1
singly linked list swap pairs... I've hit a brick wall
Last edited by Moooni; August 19th, 2008 at 06:43 AM.
-
August 16th, 2008, 07:27 AM
#2
Re: singly linked list swap pairs... I've hit a brick wall
The algorithm is :
Code:
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.
Last edited by darwen; August 16th, 2008 at 07:29 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|