Fibonacci search - 考試

Table of Contents



[課業] 國考課業相關問題,非歷屆考題的討論,如學理觀念的釐清。

遇到一個問題如下:但我求出的2是4不知為何答案為5

work through fibonacci search on an ordered file with
keys (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16)and determine
the number of key comparisons made while searching for the
keys 2,10 and 15
(for fibonacci search we need three fibonacci number f(5)=5
,f(6)=8,f(7)=13)

尋求大大解惑

--
◢████◣   ◢████◣
◢◤    ◥◣    ◢◤    ◥◣
◤      ◥◣  ◢◤      █
▎  ◢█◣  ◥◣◢◤   ◢█ █
◣ ◢◤ ◥◣       ◢◣◥◣◢◤
◥█◤ ◢◤         ◥◣

--

All Comments

Susan avatarSusan2014-07-01
f(7) (13) ->f(6) (8) -> f(5) (5) -> f(4) (3) ->f(3
) (2) -> match, 5次沒錯吧
Odelette avatarOdelette2014-07-03
我也是算4次,一開始樹的高度是5,root值=8, 8>2
Hedwig avatarHedwig2014-07-08
所以樹不用調整(13~16),所以依次搜尋8,5,3,2 共4次
Hardy avatarHardy2014-07-08
我參考答案也是5次 ,不知道觀念哪裡出錯 XD
Jacky avatarJacky2014-07-10
LOVE大我也是這樣算,ROOT是8往下尋找
Tracy avatarTracy2014-07-14
我的算法跟1樓一樣,根是F(7)=13開始,第5次找到2