next up previous
Next: Q2: Divide and conquer Up: CSL102: Special on-line examination Previous: CSL102: Special on-line examination

Q1: Longest plateau

Develop an imperative program to compute the longest plateau in a given array $ a$ of size $ > 2$ . A plateau in a sequence is an index $ i$ along with the its length $ ilen$ such that $ a[i-1] \neq a[i] = a[i+1] = ... = a[i+ilen-1] \neq a[i+ilen]$ .

For example, the longest plateau in 5 5 10 14 7 7 7 6 12 3 0 0 0 6 0 is (10,3). If the longest plateau is not unique, return the last one. Needless to say, make your program as efficient as possible.

You may write the program in any language of your choice. However it may be simplest to complete this Python program template.



Subhashis Banerjee 2009-04-03