Prolog uses general trees, not binary trees. An example is a(b,c,d(e,f,g)) where root a has 3 kids, as does kid...
Prolog uses general trees, not binary trees. An example is
a(b,c,d(e,f,g)) where root a has 3 kids, as does kid d.
It is possible to define both preorder and postorder for general trees,
although inorder of course makes no sense.
For this assignment we are interested in postorder, which is defined as
follows:
to 'visit' a tree in postorder,
you visit the subtrees of the root, in left to right order,
in postorder, and then you visit the root
Thus the example above would yield the following postorder traversal:
b c e f g d a
Write Prolog code which will perform a postorder traversal of a Prolog
tree constant. Hint: you might use 'univ', or its cousins.
Sample dialog:
?- postorder(a(b,c,d(e,f,g))).
b c e f g d a true13 years ago
10
Answer(0)
Bids(0)
other Questions(10)
- what three things cause carbon to be released into the atmosphere as carbon dioxide?
- Mr. Johnson came by the office for his annual flu shot. Nathan the medical assistant notices that the patient has...
- i require 5 in of ribbon. how many pieces of ribbon can i wrap with 30 yd
- Blood from all parts of the body, except the lungs, goes to the ___________ side of the heart
- what is the scale factor if the scale is 10 inches = 1 foot
- Essay question, 250 words min., APA format
- i need help
- Power point help
- Variation 1)If 1/3 kilogram of fish costs 35 pesos,how much will 2 and 1/2 kilograms of fish cost? 2)At 40 for every...
- Is there a site that can help me to answer this question: How much is fact and speculation in robin...