Question: Maple Unimodal

Definition: A list or sequence of numbers 
                             "a[1]"


                             "a[2]"

, ..., 
                             "a[n]"

 is unimodal if there is an index i such that 
                         
                             "a[1]"

 <= 
                             "a[2]"

 <= . . . <= 
                             "a[i]"

 >= 
                           "a[i + 1]"

 >= 
                           "a[i + 2]"

 >= . . . >= 
                             "a[n]"


That is, the sequence is non-decreasing up to some point after which it is non-increasing. Note that i can be 1 or n.  A constant sequence is considered to be unimodal.

Examples of unimodal lists:

         [1, 1, 1, 1, 1],  
         [1,2,3,4,5,4,3,2,1], 
         [1, 2, 2, 3, 4, 5, 5, 5],   
         [5, 5, 4, 4, 3, 3, 1],   
         [1, 2, 2, 3, 3, 3, 4, 4, 2, 2, 1, 1, 1]

Examples of lists that are not unimodal:

          [1, 0, 1, 0], 
          [1, 1, 2, 2, 3, 4, 5, 2, 2, 6, 4, 2, 2, 1, 0]

(a) Write a procedure unimodal to check whether or not a list of numbers is unimodal. The input should be a list and the output should be true or false. 

One way to do this is to first write procedures called  increasing and decreasing which will check whether or not a sequence is non-decreasing (
                             "a[1]"

 <= 
                             "a[2]"

 <=...) or non-increasing (
                             "a[1]"

>= 
                             "a[2]"

>=...). Then for a list L use these procedures to check the two parts L[1..i] and L[i..n], n=nops(L) for each i. If you find an i such that the first list is "increasing" and the second is "decreasing" then you can return true. 

I have up to here.

I need help with this part.

For n from 10 to 15  check whether or not the sequence of binomial coefficients  

[binomial(n,0), binomial(n,1), binomial(n,2), . . ., binomial(n,n)]

is unimodal. 

Please Wait...