Article View: cn.bbs.comp.program
Article #903Problems about Prolog
From: 10804136
Date: Tue, 28 Apr 1998 00:00
Date: Tue, 28 Apr 1998 00:00
22 lines
1219 bytes
1219 bytes
I have two problems about the binary tree. Anyone can help me to solve the
below questions.
a binary tree with appropriate Prolog structure:
5
3 8
1 4 6 9
7
a)Write a predicate to find the path from the root node to a particular node
of a tree and store it in a list.
?-path(7,Tree,List).
List=[5,8,6,7]
b)Write a predicate to produce a inorder listing of a tree.
?-inoder(tree).
1 3 4 5 6 7 8 9
Thank!
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
Technical Details
Message-ID:
<6i4sj3$ejg$1@nnrp1.dejanews.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fc86e,ef66ac5d55192e35,start X-Google-Attributes: gidfc86e,public From: 10804136@scope.cityu.edu.hk Subject: Problems about Prolog Date: 1998/04/28 Message-ID: <6i4sj3$ejg$1@nnrp1.dejanews.com> X-Deja-AN: 348427377 X-Http-User-Agent: Mozilla/3.0Gold (Win95; I) Organization: Deja News - The Leader in Internet Discussion X-Article-Creation-Date: Tue Apr 28 15:28:35 1998 GMT Newsgroups: cn.bbs.comp.program