sir/mam in the code sir write
f(i,j)=max{a[i]+min{ f(i+2,j-1),f(i+1,j)}}
why we write “min in front of f()”.
we write min to take value which is less so that we increase profit of player.
Is my explanation right?
sir/mam in the code sir write
f(i,j)=max{a[i]+min{ f(i+2,j-1),f(i+1,j)}}
why we write “min in front of f()”.
we write min to take value which is less so that we increase profit of player.
Is my explanation right?
hi @Royal_Yashasvi, what we have to do is to is to find maximum points , player 1 can win with , but we have to note here that both player are playing optimally , Playing optimally means that both players will have insight into all possible next moves and will play in such a way to maximize their chance of winning without making a mistake.
Now comming to the expression a[i]+min{ f(i+2,j-1),f(i+1,j)} now a[i] means that player 1 has chosen the ith value from the array Now we have two cases
Now , here comes the important part, since player 2 is also playing optimally due to which he will make player 1 reach a state in which he gets minimum value i.e. min{ f(i+2,j-1),f(i+1,j)}
that’s why we used min()
so our overall ans is f(i,j)=max(a,b)
where a is a[i]+min{ f(i+2,j-1),f(i+1,j)} // when player 1 choose ith value
and b is a[j]+min{ f(i+1,j-1),f(i,j-2)}
In case of any doubt feel free to ask
If you got the answer mark your doubt as resolved
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.