Finding Min/Max value of a Unimodal Function using Ternary Search

preview_player
Показать описание




.
.
.
Happy Programming !!! Pep it up 😍🤩
.
.
.
#pepcoding #code #coder #codinglife #programming #coding #java #freeresources #datastrucutres #pepcode #competitive #competitiveprogramming #softwareengineer #engineering #engineer
Рекомендации по теме
Комментарии
Автор

When dealing with doubles:
If f(x) is a quadratic equation, ax^2 + bx + c=0. The coefficient of x^2 determines whether the graph would be concave upwards or downwards.
Finding minima when a is positive:
Precision of answer would matter as it would take a hell lot of time for m1 and m2 to become equal when f(m1) == f(m2).
so when the time comes that (r-l) <10^-7 then we would assume minima to occur and return the value.

anushkajain
Автор

very detailed and much needed explanantion . Thanks bro !!

himanshugupta
Автор

Great explanation sir :-)
Can we solve Peak Index in a Mountain Array ( leetcode 852 ) using ternary search ?

adityarathi
Автор

@Pepcoding
if(fm1>fm2) {
l=m1;
r=m2;
}
else if(fm1<fm2){
r=m2;
l=m1;
}
can we do this ?? If not then which test case fail

manaskumarpanda