开发者

Is golden section search better than binary search?

开发者 https://www.devze.com 2023-01-26 14:22 出处:网络
Recently I\'ve heard an opinion that binary search may be improved by taking by splitting the range by phi (golden ration) instead of by 2. This was a big surprise to me, because I\'ve never heard abo

Recently I've heard an opinion that binary search may be improved by taking by splitting the range by phi (golden ration) instead of by 2. This was a big surprise to me, because I've never heard about such opti开发者_开发技巧mization. Is this true? Would this have been true if division by 2 and by phi was equally performant?

If not, are there any general conditions under which golden section search would perform faster than binary search?

UPD: Edited to remove link to a non-relevant Wikipedia article. Sorry for misleading.


There are two algorithms called "Fibonacci search".

The article you linked is about a numerical algorithm for finding the maximum or minimum of certain functions. It is the optimal algorithm for this problem. This problem is just different enough from the binary search problem that it should be obvious for any given case which is appropriate.

The other kind of Fibonacci search does attack the same problem as binary search. Binary search is essentially always better. Knuth writes that Fibonacci search "is preferable on some computers, because it involves only addition and subtraction, not division by 2." But almost all computers use binary arithmetic, in which division by 2 is simpler than addition and subtraction.

(The Wikipedia article currently claims that Fibonacci search could have better locality of reference, a claim Knuth does not make. It could, perhaps, but this is misleading. The tests done by a Fibonacci search are closer together precisely to the extent that they are less helpful in narrowing down the range; on average this would result in more reads from more parts of the table, not fewer. If the records are actually stored on tape, so that seek times dominate, then Fibonacci search might beat binary search—but in that case both algorithms are far from optimal.)


I may be missing something here, but after looking at the Wikipedia entry on the golden section search it seems like it doesn't solve the same problem as a binary search at all. Whereas a binary search is useful for finding a value in a sorted list, a golden section search is used to find a minimum or maximum value of a function over a range of values.


"works faster" is vague; but binary search should have the lowest worst case bound for number of accesses.

0

精彩评论

暂无评论...
验证码 换一张
取 消