 |
|
|
|
SCHOOL SUBJECTS
-
-
-
-
-
-
-
-
-
-
-
-
|
|
|
GRADE LEVELS
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
|
|
|
Post a New Question | Current Questions | Chat With Live Tutors
Homework Help Forum: computers
Posted by su on Sunday, October 4, 2009 at 6:17pm.
|
How can you write a sorting algorithm for three intergers in simple english terms before it is translated into C?
|
- computers - MathMate, Sunday, October 4, 2009 at 6:35pm
Do the three integers come in an array or in three distinct variables?
Can you clarify if the sorting algorithm should work for 3 (and no more) or is it a general algorithm that you are supposed to do?
A general one is not much more complicated, but requires the use of for-loops.
|
- computers - MathMate, Sunday, October 4, 2009 at 6:46pm
For a general sorting using bubble sort (the simplest and the slowest):
N=number of items
A(i)=item i from array A
loop i from 1 to N-1
loop j from i+1 to N
if(A(i)>A(j)) exchange A(i) and A(j)
end loop j
end loop i
|
Answer this Question
|
|
|
 |