prolog - Find the path of a node X from the root of the tree -


I want to ask you about a program, which I want to code in prologue. I want to create a function path (x, tree, path) which finds the path of node X from the root of the tree. Actually, I thought there would be three sentences.

  1. Path (X, Zero, []) , returned empty list because there is no tree
  2. Path (X, zero
  3. Path (X, tree (root, left, right), path) , return a list that contains the element of tree root
  4. / Code>, Internet Explorer

I believe that 3 sentences, I know 2 of them but I do not know what the third is. Can somebody help me out? Thank you.

your block 3) should be added in front of the current node of the returned returned path, Path (x, left, path); Note that the path (x, right, path)

the disconnection (; ) / 2 will try the first and left, on back tracking, the right branch.


Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -