Я борется с Пролога домашнее задание, как показано ниже,ПРОЛОГ (Как postorder в многоходовую дерево)
Пролог использует общие деревья, а не бинарные деревья. Пример:
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 true
Любая помощь в решении этой головоломки приветствуется.
Это домашнее задание? И, с домашней работой, вы должны сами выяснить ответ. Итак, что вы написали для решения этого? Пожалуйста, не просите кого-нибудь о переполнении стека выполнить эту работу за вас; Вместо этого попросите нас помочь с незначительными проблемами с кодом, который вы пишете. –