Mergesort of a linked list| User | Message | |
Posted : Tuesday, 25 August 2009, 08:47 | Permalink | Mark Here |
HoboBen

 
WW Entries : 9
|
Edit: solved
I'm trying to implement Mergesort as it seems to be a good choice for sorting a linked list.
I have a working bubblesort implementation, but it's far too slow for a list this size.
My code is crashing though - can anyone perhaps see where I went wrong? I think it's either crashing during the OrderTiles_MergeSort_merge procedure, or just after it.
Thanks
My tile type definition:
-->
The code:
-->
-----
github |
 | |
| Posted : Tuesday, 25 August 2009, 08:58 | Permalink | Mark Here |
HoboBen

 
WW Entries : 9
|
Whoops, spoke too soon.... I always end up solving it seconds after I post in the forum.
Fixed merge function:
-->
And it's really, really, really fast!
It takes almost no time at all, compared to minutes or hours with bubblesort.
I'm so excited to have solved it. Cool!!!!!!
-----
github |
 | |
| Posted : Wednesday, 26 August 2009, 10:26 | Permalink | Mark Here |
Phoenix

 
WW Entries : 5
| |
Smells like a proper candidate for the code snippets section, *wink wink* | | |
|
|