程式語言考古題 - 高考
By Edith
at 2015-06-24T17:13
at 2015-06-24T17:13
Table of Contents
◎高考三級/資訊處理/102年 第五題
考慮下述Prolog程式:
ancestor(x,x).
ancestor(x,y) :- ancestor(z,y), parent(x,z).
parent(Allen, John).
用一個subgoal的搜尋樹(search tree),描述此Prolog程式在執行查詢:
ancestor(Allen,X)時的執行步驟。
Ans:
(高上的解答是)
ancestor(Allen,X) → ancestor(Allen, Allen) {X = Allen} failure
→ ancestor(Allen, John) {X = John}
→ancestor(Z, John), parent(Allen, Z) {Z = John}
→ancestor(John, John) {Z = John} success
→ancestor(Allen, John) {Z = John} success
(實際用prolog得到的結果是)
1 ?- ancestor(Allen,X).
Allen = X, X = x
============================================
請問版上高手,哪個才是對的。
又如果prolog的結果是對的,那執行步驟為何?
感謝回答。
============================================
--
Tags:
高考
All Comments
By Damian
at 2015-06-28T01:15
at 2015-06-28T01:15
By Eden
at 2015-07-01T07:12
at 2015-07-01T07:12
By Olive
at 2015-07-05T05:11
at 2015-07-05T05:11
Related Posts
行政法選擇一問
By John
at 2015-06-24T12:16
at 2015-06-24T12:16
103地特三等上榜心得(會計)
By Elma
at 2015-06-23T23:53
at 2015-06-23T23:53
財務管理
By Megan
at 2015-06-23T21:40
at 2015-06-23T21:40
高考三級人事行政科目問題 麻煩前輩回復
By Belly
at 2015-06-23T00:35
at 2015-06-23T00:35
高考地政102年函授是否適用
By Faithe
at 2015-06-22T22:23
at 2015-06-22T22:23