Computer Science Canada Bubble Sort Problem |
Author: | gitoxa [ Fri May 23, 2008 4:26 pm ] | ||||
Post subject: | Bubble Sort Problem | ||||
I came up with an idea to make a bubble sorter go faster. I read "comb sort" on wikipedia, and this came ot my head, even though comb sort is something else... heh. Anyway, it's a bubble sort that goes both ways, up the array, then down, to lessen the time it takes to move small numbers from high indices to low ones. It works fine, until I try around 300 numbers. At some point, it just stops even though the numbers are not in order. I've been staring at it for a while, with no solution becoming apparent. You guys see something I'm missing?
|
Author: | richcash [ Fri May 23, 2008 6:20 pm ] |
Post subject: | Re: Bubble Sort Problem |
Your NumNums parameter is declared as nat1. nat1 is 1-byte so its range is 0-255. If you pass an argument that is greater than that it will basically be modulo-ed by 256 so your for loops will be incorrect. You should change the type of your parameter to support more bytes. |
Author: | gitoxa [ Fri May 23, 2008 6:42 pm ] |
Post subject: | RE:Bubble Sort Problem |
Oh, okay, thanks. Thought I'd gotten all the variables fixed. |