73
правки
Изменения
м
→Псевдокод
Рекурсивный вариант:
'''function''' ternarySearchMin('''double''' f, '''double''' left, '''double''' right, '''double''' eps)
'''if''' right - left < eps
'''return ''' (left + right) / 2
a = (left * 2 + right) / 3
b = (left + right * 2) / 3
Итеративный вариант:
'''function''' ternarySearchMin('''double''' f, '''double''' left, '''double''' right, '''double''' eps)
'''while''' right - left > eps
a = (left * 2 + right) / 3