Click to See Complete Forum and Search --> : Sorting Linked List


salsaddict99
October 12th, 2004, 02:14 PM
Hi,
I want to write a program in Pascal that sorts a linked list with insertion sort.
I can use two pointers, the first pointing to the current element and the second to the previous element.
And as a solution I should not copy into a new list, but only change the linking in the original list.
This problem is a little difficult for me, as I am not very experienced yet. Could anybody help me get the code for this problem?
I would really appreciate it. Thank you in advance

j0nas
October 14th, 2004, 04:22 AM
One way is to create a temporary array of pointers of each node. It is then very easy to sort the array. When the sorting is over, you need to build up the linked list again.

I don't remember Pascal (over 15 years since I was coding in Pascal), so I can't help you with the actual coding.