1

Consider a sequence A = a1, a2, a3, ... an of integers. A subsequence B of A is a sequence B = b1, b2, .... ,bn which is created from A by removing some elements but by keeping the order. Given an integer sequence A, the goal is to compute an alternating subsequence B, i.e. a sequence b1, ... bn such that for all i in {2, 3, ... , m-1}, if b{i-1} < b{i} then b{i} > b{i+1} and if b{i-1} > b{i} then b{i} < b{i+1}**


Consider an online version of the problem, where the sequence A is given element-by-element and each time, one needs to directly decide whether to include the next element in the subsequence B. Is it possible to achieve a constant competitive ratio (by using a deterministic online algorithm)? Either give an online algorithm which achieves a constant competitive ratio or show that it is not possible to find such an online algorithm.

Assume sequence [9,8,9,8,9,8, .... , 9,8,9,8,2,1,2,9,8,9, ... , 8,9,8,9,8,9]

My Argumentation: The algorithm must decide immediately if it inserts an incoming number into the subsequence. If the algorithm now gets the numbers 1 then 2 then 2 it will eventually decide that they are part of the sequence and thus by a nonlinear factor worse than the optimal solution of n-3.

-> No constant competitive ratio!

Is this a proper argumentation?

Hadi GhahremanNezhad
  • 2,377
  • 5
  • 29
  • 58
Jeahinator
  • 77
  • 7

1 Answers1

1

If I understood what you meant, your argument is correct, but the sequence you gave in the example is wrong. for example the algorithm may choose all the 9's and 8's.
You can alter your argument slightly to make it more accurate, for example consider the sequence

3,4,3,4,3,4,......, 1/5,2/6,1/5,2/6,....

Explanation:
You start the sequence with 3,4,3,4,... etc. until the algorithm picks two numbers. If it never does, it's obviously not competitive (it gets 0/1 out of n)
If the algorithm picked a 3, then 4, the algorithm must next take a number lower than 4. By continuing with 5,6,5,6,... the algorithm cannot take another number.
If the algorithm chose to take a 4 then a 3, by a similar resoning we can easily see how continuing with 1,2,1,2,... prevents the algorithm from taking another nubmer.
Thus, in any case, the algorithm cannot take more than 2 numbers for every n, which, as you stated, isn't a constant competitive ratio.

  • Thank your for your response. I think your argument is based on an online adversary model. You change the input of the ALG live to make it sufficiently bad. A competetive ratio for an online opponent holds for an oblivious adversary. Could not there be a constant competitive ratio if we reduce our opponent to an oblivious opponent? Is it like in this case sufficient to show that for any adversary model there is no constant ratio? – Jeahinator Aug 21 '19 at 06:58
  • It's not an online adversary model, but the same model you considered. As the algorithm is deterministic, the adversary "simulates" the algorithm to see what numbers it would choose, then the adversary will construct the sequence in the manner I described. –  Aug 21 '19 at 07:26
  • got it, the order of the sequence is not part of any random factor. Its already clear befor the start of ALG which numbers the algorithm picks so without any randomazation the deterministic algoithtm can be made 'useless' by choosing your mentionend sequences. – Jeahinator Aug 21 '19 at 07:33