Example: Given [1 2 3 10 7 8 9], I look for an algorithm giving [1 1 1 0 1 1 1].
I have an unsorted array as input. As output I look for a largest sorted selection.
- With "selection" I mean an array of the same length holding 1s and 0s (if the elements are selected or not).
- With "sorted" I mean that the selected elements make a sorted array - in the above example: [1 2 3 7 8 9].
- And with "a largest" I mean that there is no sorted selection that has more 1s in it.
Worst case: I have to try all 2^{0,1} possible selections. Is there a faster algorithm to do that? I dont't remember any from CS study and could not find anything online (at least with my wording).