Answer
[1. Input set of numbers]
2. Place set of numbers into an array
3. For each number in the array, compare with the next number when possible,
4. Swap with the next number if it is less than the next number
5. Calculate the quantity of elements in the array
6. Repeat 3 followed by 4 the number of times calculated in 5.
[7. Output the altered array]
The stuff in the square brackets is optional. Obviously the question did not raise input or output, however arguably data would have had to come from somewhere.
2007-09-21 02:52:28
·
answer #1
·
answered by bumbass2003 3
·
0⤊
0⤋
here is the algo....
1.put the number together in a group /array(i suggest you put the in an rray)
2.take the number and compare with the other numbers if
it's smaller than the rest then mark as the first smallest number
3.take another number and compare with the other numbers if
it's smaller than the rest and greater that then previous number in step 2 then mark as the second smallest number
repeat the steps until you reach the largest number of all
4.print the number from the smallest to largest
i hope i've helped, let me know if you get strunded
2007-09-20 22:25:32
·
answer #2
·
answered by el 2
·
0⤊
0⤋
Put the numbers into a one dimensional array e.g.
123,289,276,194
Set a boolean flag to indicate a swap of the order of successive numbers in the array and set it to false, i.e. not swapped.
For each number in the array check if the next number is greater or less than the previous number and loop the function. If the succeeding number in the array is smaller than the preceding number swap it with the preceding number and set the swap variable to true. Keep going around the loop until the swap boolean variable is false again i.e. no number in the array is larger than the number after it.
2007-09-20 21:06:12
·
answer #3
·
answered by Anonymous
·
0⤊
0⤋
It appears to me that the point of the question was to write an algorithm to sort a set of numbers. You wrote "sort the numbers". You need to be more specific.
2007-09-20 20:46:30
·
answer #4
·
answered by Lumberjack 3
·
0⤊
1⤋
That is not the desired algorithm, because it is not supposed to be an algorithm to print out the numbers sorted. It should be the actual sort operation itself, here shown as just one line (line 2.) in this algorithm.
2007-09-20 20:47:34
·
answer #5
·
answered by iNsTaNt pUdDiNhEaD 6
·
0⤊
1⤋
i think the biggest error is that...... the question never ask u to print the sorted number.. why should u? lol just kidding man.. i'm preparing question for my student.. just trying to kick back and relax a bit here..
I agree with both answer above.. u should be more definitive in sorting section. The point of the question to know whether u know or not how to do the sorting procedure.. u should be more precise on that. if i am ur lecturer, i would wanna see how and WHEN u implement the loop and do the comparing.
humm maybe i'll include this in one of my question.. hahaha!! thanx man..
2007-09-20 20:55:03
·
answer #6
·
answered by jackel_sinister 2
·
0⤊
1⤋
You need to show how you will sort the grouped numbers
2007-09-20 20:47:09
·
answer #7
·
answered by jasonMe 1
·
0⤊
1⤋
Look up something called a fast sort, its a very fast and efficient number sorting routine, you will find a lot of information on wikipedia and the net about it.
2007-09-20 20:46:56
·
answer #8
·
answered by thed0nk 1
·
0⤊
1⤋
I think you need to be specific in how you're going to sort the numbers.
2007-09-20 20:45:34
·
answer #9
·
answered by SoulDawg 4 UGA 6
·
0⤊
1⤋