Wednesday, September 22, 2010

Homework from the class of Sept 22, 2010

Write a routine to test if a given list of numbers is sorted
IsSorted(n, a1, a2, …, an)
{
         // return YES if a1, … an is sorted
         // else return NO
}
Your algorithm should work for any 'n', any set of numbers, a1, ...., an, and for any permutation of numbers a1,... an, AND should finish in finite time.

Then answer the following questions
–Why will your solution work for any n?
–Why will your solution work for any given set of numbers?
–Why will your solution work for any permutation of those numbers?
–Why will your solution finish in finite time?

Deadline: Sunday, Sept 26, 2010.

No comments:

Post a Comment