Questions: 69

Answers by our Experts: 50

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search & Filtering

Translate the following sentences into a Prolog program (10)


Everyone who teaches programming module is smart.


Craig teaches the programming module.


Craig’s brother teaches the mathematics module.


The programing module is interesting.


Craig’s sister teaches all modules.



QUESTION ONE (20 MARKS)

1.1 Consider the state space graph shown below. P is the start state and V is the goal state. The costs for each edge are shown on the graph. Each edge can be traversed in both directions.

1.1.1 Use Breadth-First Search to generate the shortest path from P to V. (10)

1.1.2 Apply the Depth First Search method to find a path from P to V. (10)



Translate the following sentences into a Prolog program (10)

Everyone who teaches programming module is smart.

Craig teaches the programming module.

Craig’s brother teaches the mathematics module.

The programing module is interesting.

Craig’s sister teaches all modules.


Program(Queen Victoria's family):


 male(albert).

 male(edward).

 female(alice).

 female(victoria).

 parents(edward,victoria,albert).

 parents(alice,victoria,albert).

 sister_of(X,Y):-

   female(X),

   parents(X,M,F),

   parents(Y,M,F).


On the query sister_of(X,Y) more one answer can be

returned. Explain how all the answers are obtained, 

and what they are.


You are to write a simple program in Prolog to find a path through a maze. Your input will consist of facts of the form

    pway(a, b, 10).

indicating that there is a passageway from intersection a to intersection b of length 10 meters. You are to write a rule

    solve(X, Y, P, N) :- ...

that will find a path P of length N (if one exists) from intersection X to intersection Y. The intent is that the user will invoke solve as a query, specifying X and Y as constants and P and N as variables.

Here is a concrete example. Suppose the database contains the following rules:

    pway(a, b, 10).
    pway(b, c, 15).
    pway(d, c, 5).
    pway(d, b, 10).

If the user types

    solve(a, d, P, N)

the Prolog interpreter might respond with

    P = [a, b, c, d]
    N = 30
Arrange in ascending order the last THREE (3) elements in the list of 5 elements. For example, if the original list consists of [12, 3, 9,4,1] then the new list becomes [12,3,1,4,9]. For the ascending sorting, there is a built in predicate called sort(A,X). It sorts the elements in List A and the results of that sort is saved in List X
Write a prolog program to convert any 4-bit binary number to octal number.
Write a program to convert the given text, ‘Today, is a good day. Are you going out?’ into a list of words and rearrange the words to form a new text:
Are you going out? Today, is a good day.
Write a prolog program to convert any 4-bit binary number to octal number.
(b) Arrange in ascending order the last THREE (3) elements in the list of 5 elements. For example, if the original list consists of [12, 3, 9,4,1] then the new list becomes [12,3,1,4,9]. For the ascending sorting, there is a built in predicate called sort(A,X). It sorts the elements in List A and the results of that sort is saved in List X.
LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS