Monday, September 27, 2010

IsSorted

BEGIN
count list
Loop an-1 times
if a1<a2
move to next value
else
display no
END

This algorithm will return the correct answer because it will go through the array of numbers and check each to see if the next one is larger than the previous. It will end in infinite time because the loop is set to occur (an - 1) times.

No comments:

Post a Comment