what is the greedy or dynamic programming approach of this?

101 Views Asked by At

we have a sequence of REAL numbers.all of the numbers are unique.we want to have an ascending sequence by changing some of these values.we are allowed to change any arbitrary numbers.how to find the optimum algorithm to determine the minimum number of necessary changes to make this sequence? we can use greedy or dynamic programming approach.

1

There are 1 best solutions below

0
On BEST ANSWER

first find longest increasing subsequence http://en.wikipedia.org/wiki/Longest_increasing_subsequence

then change all numbers which do not belong to this subsequence to fit the rule

(proof: if we change less numbers and acquire ascending sequence, then the numbers which were not changed were initially forming increasing subsequence longer then 'longest')