Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Write Prolog code which will perform a postorder traversal

Status
Not open for further replies.

rukman

Programmer
Nov 4, 2011
7
US
tree constant. Hint: you might use 'univ', or its cousins.
?- postorder(a(b,c,d(e,f,g))).
b c e f g d a true



Hi ,
I am trying this problem but , the output is undefined predicate postorder. I think i wrote correctly but, it is not working.
postorder(void,[]).
postorder(tree(X,L,R),Xs):-
postorder(L,Ls),postorder(R,Rs),append(Rs,[X],Rs1),append(Ls,Rs1,Xs).


can anyone please help me. Urgent...:(

Thank you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top