0% found this document useful (0 votes)
54 views4 pages

Universiti Teknologi Mara Final Examination: Confidential CS/JAN 2012/CSC563

The document appears to be an exam for an Artificial Intelligence Programming Paradigms course. It contains 6 questions testing knowledge of Prolog programming concepts like differences between Prolog and Java, declarative vs procedural programming, backtracking, recursion, cuts, defining relations using facts and rules, queries, and writing a short Prolog program.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views4 pages

Universiti Teknologi Mara Final Examination: Confidential CS/JAN 2012/CSC563

The document appears to be an exam for an Artificial Intelligence Programming Paradigms course. It contains 6 questions testing knowledge of Prolog programming concepts like differences between Prolog and Java, declarative vs procedural programming, backtracking, recursion, cuts, defining relations using facts and rules, queries, and writing a short Prolog program.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

CS/JAN 2012/CSC563

CONFIDENTIAL

UNIVERSITI TEKNOLOGI MARA


FINAL EXAMINATION

COURSE

ARTIFICIAL INTELLIGENCE PROGRAMMING


PARADIGMS

COURSE CODE

CSC563

EXAMINATION

JANUARY 2012

TIME

3 HOURS

INSTRUCTIONS TO CANDIDATES
1.

This question paper consists of six (6) questions.

2.

Answer ALL questions in the Answer Booklet. Start each answer on a new page.

3.

Do not bring any material into the examination room unless permission is given by the
invigilator.
Please check to make sure that this examination pack consists of:
i)
ii)

the Question Paper


an Answer Booklet - provided by the Faculty

DO NOT TURN THIS PAGE UNTIL YOU ARE TOLD TO DO SO


This examination paper consists of 4 printed pages
Hak Cipta Universiti Teknologi MARA

CONFIDENTIAL

CONFIDENTIAL

CS/JAN 2012/CSC563

Answer ALL questions.

QUESTION 1
a)

Describe THREE (3) differences between Prolog and Java programming language.
(6 marks)

b)

Define the following terms used in Prolog:


i)
ii)
iii)
iv)
v)

Declarative
Procedural
Backtracking
Recursive
Cut
(10 marks)

QUESTION 2
Give the answer for the queries below:
a)

?- w = 10+11+12.

b)
C)
d)
e)
f)
g)

? - X i s 13 + 14 + 1 5 .
? - Y == 16 + 17 + 1 8 .
?- var(Z) , Z= 9.
?- 0.9*1000 =:= 9*100.
? - [ 1 , 2 | [3 | [ 4 ] ] ] = [A| [ B , C | [ D ] ] ] , C i s
?- t p , q , r , s ] = [Z,_|T] .

A+B.

h) ?- likes(fasha, faizal) = ..([x|Y]).


i) ?- M=. . [k,x,f (x,y)] .
j)

?-

[[w,x] , [ y , z ] ] = [A,B|T] .

(10 marks)

QUESTION 3
Assume a Prolog database contains facts for male/1, female/1 and parent/2. Define the
following relations in Prolog.
a)
b)
c)
d)
e)

mother/2
son/2
brother/2
grandfather/2
granddaughter/2
(18 marks)

Hak Cipta Universiti Teknologi MARA

CONFIDENTIAL

CONFIDENTIAL

CS/JAN 2012/CSC563

QUESTION 4
Consider the following Prolog program:
q(6) .
q(7) :q(10) .

!.

Write all answers to the queries:


a)
b)
C)

?- q(X) .
? - q(X) , q(Y) .
? - q(X) , ! , q(Y) .
(18 marks)

QUESTION 5
Write a Prolog program to determine whether an integer input is an ODD or an EVEN
number. The program will terminate if the user enter 0. The program should correspond as
follows:
?- s t a r t .
Enter a number: 5.
5 is an odd number.
Enter a number: 4.
4 is an even number.
Enter a number: 0.
Exiting...

(13 marks)

Hak Cipta Universiti Teknologi MARA

CONFIDENTIAL

CONFIDENTIAL

CS/JAN 2012/CSC563

QUESTION 6
Suppose that a Prolog database contains the following rules and facts:
f ( B , C, D, E) : g ( C , D) , h ( B , A) , i ( A ,
g(C, D ) : j(D), k(C,

E) .

D).

h ( B , A) : k(A, B ) .
h ( B , A) : j(C), j(D),

B is

C+D, k ( B ,

A).

i(C,m(D)):D i s C+l.
j (2) .
j (3) .
k(2,3) .
k(4,4) .
k(5,8) .

List all the solutions for the query:


?-

f(B,

C,

D,

E).

(25 marks)

END OF QUESTION PAPER

Hak Cipta Universiti Teknologi MARA

CONFIDENTIAL

You might also like