Hi! I recently started using Alice 2.2.
I'm having some trouble sorting an array. The array has 6 predefined numbers which I want to sort and print them on screen.
I've attached the world file. Any help would be very much appreciated!!
There are multiple ways of sorting an array. One method is the insertion sort algorithm, it is not my favorite(selection sort is my preference), but it will do.
I'm sorry I didn't make it in your world, but hopefully you can transcribe it.
Tell me if you don't understand the code.
"Two things are infinite: the universe and human stupidity; and I'm not sure about the the universe."-Albert Einstein
I have deleted everything except the sorting loop.
I noticed that it works fine with some decimal number but not with every decimal number... strange...
Can you please take a look at this file? I get an "out of bounds" error with these decimals...
Computers are just fascinating aren't they. I have only one idea as to why this is happening, but even so 1-1=0 which is a plausible index to have. It is almost as if the computer is ignoring the program and doing what it wants to do
I'm sorry I just don't know.
"Two things are infinite: the universe and human stupidity; and I'm not sure about the the universe."-Albert Einstein
Last edited by legolizard; 06-01-2011 at 06:21 PM.
Okay I still don't know why the insertion sort algorithm isn't working because I just "translated" the program into C++ and it worked perfectly fine. So we are going to have to use the more difficult and slower selection sort algorithm.
Here is a world using this method...
"Two things are infinite: the universe and human stupidity; and I'm not sure about the the universe."-Albert Einstein
Last edited by legolizard; 06-11-2011 at 06:52 PM.
Okay I still don't know why the insertion sort algorithm isn't working because I just "translated" the program into C++ and it worked perfectly fine. So we are going to have to use the more difficult and slower selection sort algorithm.
Here is a world using this method...
What is the value of "i" when the program crashes, and what are you doing with it?