Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Prolog Programming. a) Implement a predicate f(X, N) for a function f(n) such that f(0) = 4, f(n) = 2 * f(n-1) + 5. Please

Prolog Programming.

a) Implement a predicate f(X, N) for a function f(n) such that f(0) = 4, f(n) = 2 * f(n-1) + 5.

Please implement using RECURSION!

Test Cases:

?- f(0, N). N=4. ?- f(1, N). N=13.

b) Implement numOfHops(X, Y, N) such that Y can be reachable from X in N hops of friendships. (Use RECURSION please)

Facts: friend(alice, bob). friend(bob, charles). friend(charles, dorothy). friend(dorothy, eason).

Test cases: ?- numOfHops(alice, bob, N). N = 1. ?- numOfHops(alice, charles, N). N = 2.

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

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions