Sunday, September 26, 2010

Check if in Order

1. Create variable A
2. Have variable A equal the first number in the list
3. Proceed to check if A is larger than the next number
4. If A is larger than any of the numbers checked Prompt No
5. If A is smaller than the checked number have it equal that number then repeat step 3
6. If A has checked all the numbers given and was never larger prompt Yes

This will work because it will test all the given numbers in order to check if they are from least to greatest. It will finish in finite time because it will only test n-1 times before it prompts yes or no. The program will terminate after it prompts the yes or no statement.

No comments:

Post a Comment