logoalt Hacker News

madcaptenoryesterday at 2:50 PM1 replyview on HN

Isn't it a bit better on average, although not as much as you'd hoped? For example 19 steps of binary search get you down to 1/524288 of the original search space with 19 comparisons. 12 steps of ternary search get you down to 1/3^12 = 1/531441 of the original search space with, on average, 12 * 3/2 = 18 comparisons.


Replies

jstanleyyesterday at 3:09 PM

Maybe! But you can see the other comment that points out I was wrong and it is actually 5/3 comparisons so it still works out worse.