Prolog uses general trees, not binary trees. An example is _x000D_ _x000D_ a(b,c,d(e,f,g)) where root a has 3 kids, as does kid d._x000D_ _x000D_ It is possible to define both preorder and postorder for general trees, _x000D_ although inorder of course makes no sense._x000D_ _x000D_ For this assignment we are interested in postorder, which is defined as_x000D_ follows:_x000D_ _x000D_ to 'visit' a tree in postorder, _x000D_ you visit the subtrees of the root, in left to right order,_x000D_ in postorder, and then you visit the root_x000D_ _x000D_ Thus the example above would yield the following postorder traversal:_x000D_ _x000D_ b c e f g d a_x000D_ _x000D_ _x000D_ Write Prolog code which will perform a postorder traversal of a Prolog_x000D_ tree constant. Hint: you might use 'univ', or its cousins._x000D_ _x000D_ Sample dialog:_x000D_ _x000D_ ?- postorder(a(b,c,d(e,f,g)))._x000D_ b c e f g d a true
WhatsApp us