Bubble Sort

4 views
Skip to first unread message

Grant

unread,
Jul 29, 2011, 4:39:46 PM7/29/11
to BYU 142 Summer 2011
I can get my bubble sort to spit out 20 "random" numbers in ascending
order... but there are repeats of several numbers and sometimes when I
run it I get all of the same number. For instance one output was:
59
68
68
68
68
68
69
69
69
97
97
97
97
97
97
97
97
97
97
97


Is that okay? Or could I do better?

Sarah Morley

unread,
Jul 29, 2011, 4:45:44 PM7/29/11
to byu-142-s...@googlegroups.com
I'd guess that you are swapping values incorrectly. The chances of getting that many duplicates that often is pretty slim. Try making your own int array with hard coded values to see if that's being sorted correctly.

Sarah
Reply all
Reply to author
Forward
0 new messages