Computer Science Canada help needed on sort routines |
Author: | Leiak [ Sun Jan 25, 2004 5:47 pm ] |
Post subject: | help needed on sort routines |
i am doing a grade 11 compsci exam tomorrow and i know everything fine except im a lil in the dark on the sort routines i know its like for x : 1..100 for y:1..100-x or something likethat then u set em all to equal each other but im not 100% sure any help is appreciated |
Author: | AsianSensation [ Sun Jan 25, 2004 5:48 pm ] | ||
Post subject: | |||
bubble sort:
|
Author: | McKenzie [ Sun Jan 25, 2004 7:54 pm ] | ||
Post subject: | |||
google "bubble sort" ==
I know it's in C, but ... give it a look |
Author: | Delos [ Sun Jan 25, 2004 8:54 pm ] |
Post subject: | |
Good grief! Put that Java away! |
Author: | shorthair [ Sun Jan 25, 2004 9:07 pm ] |
Post subject: | |
Quote: McKenzie Wrote , "i know its in C but.." Quote: Delos Wrote , "good grief put that java away" Am i missing somthing |
Author: | Delos [ Sun Jan 25, 2004 9:16 pm ] |
Post subject: | |
shorthair wrote: Quote: McKenzie Wrote , "i know its in C but.." Quote: Delos Wrote , "good grief put that java away" Am i missing somthing My bad...didn't read properly. But it looks like JAVA! Argggghhhh. Seriously, the whole curly brackets and double + thing and all. Yes, I am aware of those being industry standard. Sorta. |
Author: | shorthair [ Sun Jan 25, 2004 9:23 pm ] |
Post subject: | |
Okay , i wsa just wondering how ou got java from his post , ![]() ![]() |
Author: | Dan [ Sun Jan 25, 2004 10:25 pm ] |
Post subject: | |
well techaly there is almost no difencte between the code in java and the code in c or c++ for that. also you left out a break there for the if.... |
Author: | McKenzie [ Sun Jan 25, 2004 10:35 pm ] |
Post subject: | |
McKenzie wrote: google "bubble sort" ==
The point I was making is don't be afraid to jump on google to find code. If I were to type it myself I wouldn't use C in a Turing forum. I invested a whole 10 seconds finding the code. As far as the break goes the basic version of the bubble sort doesn't have it. |
Author: | Delos [ Mon Jan 26, 2004 10:22 am ] |
Post subject: | |
shorthair wrote: Okay , i wsa just wondering how ou got java from his post ,
![]() ![]() Bubble sort...bubble sort. How do I scoff thee? Anyhow, bubble sorts are almost entirely deprecated. i.e., you would never use one to sort a list of more than 2 elements. What they do is compare adjacent elements, and if the first is greater than the second, it switches them. It keeps doing this until the list is completely sorted. Eg. 3 4 1 8 4 6 3 4 1 4 8 6 3 1 4 4 6 8 1 3 4 4 6 8 That may seem odd, the way it switches, but that's about how it works. For a short list, no problem. For the average list that one would need sorted...it is sloooooooow. |