Post a New Question


posted by .

How can you write a sorting algorithm for three intergers in simple english terms before it is translated into C?

  • computers -

    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 -

    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

First Name
School Subject
Your Answer

Related Questions

More Related Questions

Post a New Question