[课业] Fibonacci search

楼主: kissme520 (牛转乾坤)   2014-06-27 15:59:57
[课业] 国考课业相关问题,非历届考题的讨论,如学理观念的厘清。
遇到一个问题如下:但我求出的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)
寻求大大解惑
作者: claudia4096 (泠)   2014-06-27 16:27:00
f(7) (13) ->f(6) (8) -> f(5) (5) -> f(4) (3) ->f(3) (2) -> match, 5次没错吧
作者: lovegarden (衙门做IT)   2014-06-27 22:30:00
我也是算4次,一开始树的高度是5,root值=8, 8>2所以树不用调整(13~16),所以依次搜寻8,5,3,2 共4次我参考答案也是5次 ,不知道观念哪里出错 XD
楼主: kissme520 (牛转乾坤)   2014-06-28 09:45:00
LOVE大我也是这样算,ROOT是8往下寻找
作者: canatmis (人生就是如此~)   2014-06-28 11:01:00
我的算法跟1楼一样,根是F(7)=13开始,第5次找到2

Links booklink

Contact Us: admin [ a t ] ucptt.com