Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

PROLOG multiple choice questions Please answer with full explanations 18. What i

ID: 3735480 • Letter: P

Question

PROLOG multiple choice questions

Please answer with full explanations

18. What is the following mystery/2 about?

mystery([],[]).
mystery([X|Y],Z) :- mystery(Y,W), takeout(X,Z,W).   
takeout(X,[X|R],R).
takeout(X,[F|R],[F|S]) :- takeout(X,R,S).

A. append

B. prefix

C. permutation

D. reverse

E. suffix

F. member

G. sort

22 Which of the following selections is correct?
This ____ is to add a new fact or rule (clause).

A. args/3

B. assert/1

C. atom/1

D. clause/2

E. call/1

F. findall/3

G. functor/3

H. ground/1

I. op/3

J. retract/1, retractall/1

K. var/1

L. =, =

M. ==, ==

23. What is the predicate ___ for the following query and its result?
          ?- ____(f(a,b),F,A).
          A = 2
          F = f

A. args/3

B. assert/1

C. atom/1

D. clause/2

E. call/1

F. findall/3

G. functor/3

H. ground/1

I. op/3

J. retract/1

K. var/1

L. =, =

M. ==, ==

24. What is the predicate ___ for the following query and its result?

?- ___(2,loves(richard, sarah), X).
X = sarah
         

A. arg/3

B. assert/1

C. atom/1

D. clause/2

E. call/1

F. findall/3

G. functor/3

H. ground/1

I. op/3

J. retract/1

K. var/1

L. =, =

M. ==, ==

27. Complete the second clause of the following Prolog program for member/2 where member(X, Y) checks whether X is an element (a member) of a list Y.

member(X,[X|R]).
member(X,[Y|R]) :- ____________.

A. member(X,R).

B. member(X,Y).

C. member(_,R).

D. member(Y,R).

E. member(X,Y).

Explanation / Answer

18. D. reverse

22.A rule can be viewed as an extension of a fact with added conditions that also have to be satisfied for it to be true.

D. clause/2

23.D. clause/2

24.A. arg/3

27. A. member(X,R).

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote