

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


COP4020 Spring 2008 Sample Exam Solutions 1. proc T(); proc Ta(); Ta(); N = 1; Tc(); while NT = โ,โ { while NT = โaugโ { Read(โ,โ); Read (โaugโ; ) Ta(); Tc (); N ++; BuildTree (โaugโ, 2); } } if N > 1 BuildTree(โtauโ, N); end; end; proc Tc(); B(); if NT = โ->โ { Read (โ->โ); Tc (); Read (โ|โ); Tc (); BuildTree (โ->โ, 3); } end; 2. (1) No, the two lists do not unify. Unifying them would require first that [Y,a] unify with [a,X]. They do unify, but Y is bound to a, and so is X. Next, Y would have to unify with b, which it can't, because it is already bound to a. Changing the first list to [ [Y, a], a, c] would solve the problem. (2) Uncle(X,Y) :- Parent(W,X), Parent(Z,W), Parent(Z,Y)