Need Help about Ternary Search on integers

Revision en1, by Iron_Price, 2020-10-02 13:12:06

Is there anything wrong using this approach for ternary search on integers?
while (R — L >= 3) { ... } ans = inf; for(i = L; i <= R; i++) ans = min(ans, f(i));

This blog shows a different way and tells not to use to approach above. But I don't understand why.

Tags ternary search

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English Iron_Price 2020-10-02 19:11:40 197
en1 English Iron_Price 2020-10-02 13:12:06 365 Initial revision (published)