Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The above image shows a binary tree. Write a series of predicates parentOf/2 that records if a node is a parent of another (parentOf is

The above image shows a binary tree. Write a series of predicates parentOf/2 that records if a node is a parent of another (parentOf is shown as an outgoing arrow where the parent node is the source and the child node is the destination). The first two predicates are:

parentOf(a,h) parentOf(a,b) parentOf(h,b) 

Ensure you use lowercase letters to represent the nodes. There should be 8 parentOf lines in your program.Now write a predicate ancestorOf/2 using recursion which checks if the first parameter is an ancestor of the second. You must use recursion for this predicate. Example output is:

ancestorOf(a,d). true. ancestorOf(h,i). true. ancestorOf(h,e). true. ancestorOf(g,f). false. 

Note: you must use recursion to write the ancestorOf predicate.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MongoDB Applied Design Patterns Practical Use Cases With The Leading NoSQL Database

Authors: Rick Copeland

1st Edition

1449340040, 978-1449340049

More Books

Students also viewed these Databases questions

Question

LO1 Identify why performance management is necessary.

Answered: 1 week ago