SOLUTIONS RATED A+
✔✔Given the Scheme code below, answer the following question related the Fantastic
Four abstract approach.
(define dtob (lambda (N) ; line 1
(if (= N 0) (list 0) ; line 2
(append (dtob (quotient N 2)) ; line 3
(list (remainder N 2)))))) ; line 4
What line of code contains the size-M problem, where M < N? - ✔✔line 3
✔✔Given the Scheme code below, answer the following question related the Fantastic
Four abstract approach.
(define dtob (lambda (N) ; line 1
(if (= N 0) (list 0) ; line 2
(append (dtob (quotient N 2)) ; line 3
(list (remainder N 2)))))) ; line 4
What lines of code define the step that construct the solution to size-N problem? -
✔✔lines 3 and 4
✔✔What is equivalent to the expression below?
(car (cdr '(1 2 3 4 5)) - ✔✔(cadr '(1 2 3 4 5))
✔✔Given this expression, what is the expected result?
(car (cdr '(1 2 3 4 5)) - ✔✔2
✔✔Which of the following programming languages most closely follows the stored
program concept? [C, Lisp, Prolog, Scheme] - ✔✔C
✔✔Storage of instructions in computer memory to enable it to perform a variety of tasks
in sequence or intermittently - ✔✔stored program concept
✔✔Prolog is based on [Boolean logic, lambda calculus, predicate logic, Turing
machine]. - ✔✔predicate logic
✔✔There are three kinds of clauses in a Prolog program: facts, goals, and rules. Which
of the following is true: A) A fact can be considered a special case of a goal, B) A fact
, can be considered a special case of a rule, C) A rule can be considered a special case
of a goal, or D) A rule can be considered a special case of a fact. - ✔✔B
✔✔What mechanism cannot be used for passing values between clauses within a
Prolog rule? [call-by-alias, call-by-value, return value, all of the above] - ✔✔return value
✔✔If you want to pass multiple values out of a Prolog rule, which of the following
methods is valid? A) Use multiple named variables to hold the values, or B) Use
multiple return statements in the predicate - ✔✔A
✔✔A goal clause and a fact unify if [their arities are the same, their corresponding
arguments match, their predicates are the same, all of the above]. - ✔✔all of the above
✔✔The arity of a predicate is the [body, head, neck, number of arguments] of the
predicate. - ✔✔number of arguments
✔✔The scope of a Prolog variable is within A) a single clause in a rule, B) a single rule,
C) the body of the next rule, or D) the fact/rule base. - ✔✔B
✔✔When will a circular definition of a Prolog rule cause a dead-loop? - ✔✔when no
match can be found
✔✔What is an anonymous variable in Prolog called? - ✔✔placeholder
✔✔What is the output when the following Prolog goal is executed?
?- member(apple, [orange, apple, pear]). - ✔✔true?
✔✔Assume we have the following fact in a Prolog factbase: child_of(mary, [amy, david,
conrad]). What is the output when the following goal is executed? ?- child_of(mary,
[amy | T]). - ✔✔T = [david, conrad]
✔✔Assume we have the following fact in a Prolog factbase: child_of(mary, [amy, david,
conrad]). What is the output when the following goal is executed? ?- child_of(mary,
[amy | [H | conrad]]]). - ✔✔H = david
✔✔What is the output when the following Prolog goal is executed? ?- member(X, [81,
25, 9, 29]), Y is X*X, Y=400. - ✔✔X=9 X=81
✔✔Given the following recursive rules in Prolog:
foo(X, [X]).
foo(X, [ _ | T]) :- foo (X, T).