0 Replies - 901 Views - Last Post: 12 September 2010 - 08:22 AM Rate Topic: -----

#1 Apprentice123   User is offline

  • D.I.C Regular

Reputation: -16
  • View blog
  • Posts: 265
  • Joined: 30-June 08

Tree in Prolog

Posted 12 September 2010 - 08:22 AM

How can I determine the height of a tree in prolog?

%X is a tree and Y height
height(X, Y)

height(nil,0). %Not element on tree

%Nl -> Node left || Nd -> Node right
height(tree(Nl, root, Nr), Y) :-  
%How do I check if Nl and Nr is nil to return Y=1
%How to go all the Nl and Nr to return the largest of them? 


Is This A Good Question/Topic? 0
  • +

Page 1 of 1