How to search max/min in functions which have equal elements?

Revision en1, by alan4ik, 2020-12-13 11:05:47

I am a big fan of Ternary Search.

But the fact that we can use it only in strictly increasing and strictly decreasing functions upsets me.

I am asking how to deal with functions which can have equal values (i.e. $$$f(i) \lt = f(i + 1)$$$ $$$[i \lt j]$$$, $$$f(i) \gt = f(i + 1)$$$ $$$[i \gt = j]$$$).

For example with this function $$$f(x) =$$$ {$$$1, 2, 1, 1, 1, 1, 1, 1, 1, 1$$$}.

Tags ternary search, asking, functions, just wondered

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English alan4ik 2020-12-13 11:05:47 478 Initial revision (published)