Tuesday, September 7, 2010

Sorting - Computer Science

Two rules for sorting

  • The output is in a non decreasing order. 
  • The output is a reordering of the input. 
Pseudo-code
Begin
Repeat five times
Prompt user for number 
End repeat

Take first number
 if
  number is smaller than number to the right leave it.
 else
  switch with  the first number to that right that is smaller.
 End if
End

So I didn't really know what you expected but I worded the process out as best as I could.

1 comment:

  1. Will your algorithm terminate?
    Will it produce the right result?

    ReplyDelete