123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|594|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> Cobra -> Mergesort of a linked list

Tue, 25 Aug 2009, 09:47
HoboBen
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:



-=-=-
blog | work | code | more code
Tue, 25 Aug 2009, 09:58
HoboBen
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!!!!!!

-=-=-
blog | work | code | more code
Wed, 26 Aug 2009, 11:26
Phoenix
Smells like a proper candidate for the code snippets section, *wink wink*