Consider this list:
2,1, 4,3, 6,5, 8,7, 10,9, ..., 2m,2m-1
The longest increasing sequence length of this list is m = n/2
. You can trivially construct such a sequence by picking one element from each "pair" of items. Since there are m
such pairs, and the choices are independent, there are 2^m
longest increasing sequences.
So your algorithm can't be faster than Ω(2^(n/2))
, because there's at least that much output in some cases.
To get around this you need to tweak the problem, perhaps by doing an output-sensitive analysis or by counting the number of sequences instead of actually generating them. Another alternative is to output a compact way that can be used later to generate all the sequences, which is what linear time unification algorithms do.